Advertisement
mazaya

Enc/Dec Teks

Sep 17th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. # pake python3 ya mamank
  2. # key ganti sendiri
  3. # cara generate key
  4. # import os;print(os.urandom(16))
  5.  
  6. class modol:
  7.     def __init__(self, x):
  8.         # ini key
  9.         self.key = b'\x19\r\xe64.\xb0\x93\xe9\x8d.\x83\x032?\xe6{'
  10.         self.x = x
  11.    
  12.     def enc(self):
  13.         teks = self.x
  14.         a = pyaes.AESModeOfOperationCTR(self.key)
  15.         b = a.encrypt(teks)
  16.         c = compress(b)
  17.         return str(b64encode(c)).split("'")[1]
  18.    
  19.     def dec(self):
  20.         try:
  21.             teks = self.x
  22.             f = pyaes.AESModeOfOperationCTR(self.key)
  23.             a = b64decode(teks)
  24.             b = decompress(a)
  25.             return str(f.decrypt(b)).split("'")[1]
  26.         except:
  27.             return "not found"
  28.  
  29. def home():
  30.     os.system('clear')
  31.     print("[ Teks Encrypt / Decyrpt ]")
  32.     print("[ Coded by: SalisM3 ]\n")
  33.     print("1). Encrypt")
  34.     print("2). Decrypt\n")
  35.     pilih = int(input('[?] Pilih >>> '))
  36.     if pilih == 1:
  37.         teks = str(input('[?] Teks: '))
  38.         a = modol(teks)
  39.         out = a.enc()
  40.         print("[+] Output: " + str(out))
  41.     elif pilih == 2:
  42.         teks = str(input('[?] Teks: '))
  43.         a = modol(teks)
  44.         out = a.dec()
  45.         print("[+] Output: " + str(out))
  46.  
  47. try:
  48.     from base64 import *
  49.     from zlib import *
  50.     import os, pyaes
  51.     home()
  52. except ImportError:
  53.     print("[+] pip install pyaes")
  54. except KeyboardInterrupt:
  55.     print("[!] Exit: Ok")
  56. except Exception as e:
  57.     print("[!] " + str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement