SHARE
TWEET

Enc/Dec

Zay-7 Oct 21st, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # python3
  2. # generate key
  3. # import os;print(os.urandom(16))
  4.  
  5. class modol:
  6.     def __init__(self, x):
  7.         # ini key
  8.         self.key = b'\x19\r\xe64.\xb0\x93\xe9\x8d.\x83\x032?\xe6{'
  9.         self.x = x
  10.    
  11.     def enc(self):
  12.         teks = self.x
  13.         a = pyaes.AESModeOfOperationCTR(self.key)
  14.         b = a.encrypt(teks)
  15.         c = compress(b)
  16.         return str(b64encode(c)).split("'")[1]
  17.    
  18.     def dec(self):
  19.         try:
  20.             teks = self.x
  21.             f = pyaes.AESModeOfOperationCTR(self.key)
  22.             a = b64decode(teks)
  23.             b = decompress(a)
  24.             return str(f.decrypt(b)).split("'")[1]
  25.         except:
  26.             return "not found"
  27.  
  28. def home():
  29.     os.system('clear')
  30.     print("[ Teks Encrypt / Decyrpt ]")
  31.     print("1). Encrypt")
  32.     print("2). Decrypt\n")
  33.     pilih = int(input('[?] Pilih >>> '))
  34.     if pilih == 1:
  35.         teks = str(input('[?] Teks: '))
  36.         a = modol(teks)
  37.         out = a.enc()
  38.         print("[+] Output: " + str(out))
  39.     elif pilih == 2:
  40.         teks = str(input('[?] Teks: '))
  41.         a = modol(teks)
  42.         out = a.dec()
  43.         print("[+] Output: " + str(out))
  44.  
  45. try:
  46.     from base64 import *
  47.     from zlib import *
  48.     import os, pyaes
  49.     home()
  50. except ImportError:
  51.     print("[+] pip install pyaes")
  52. except KeyboardInterrupt:
  53.     print("[!] Exit: Ok")
  54. except Exception as e:
  55.     print("[!] " + str(e))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top