Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import string
- from base64 import b64decode, b64encode
- from Crypto.Cipher import AES
- from hashlib import md5
- from Crypto.Hash import HMAC
- from gzip import *
- BLOCK_SIZE = 16
- pad = lambda s: s + bytearray(((BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)).encode("utf-8"))
- #HMAC_SECRET = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(16))
- #key = md5(''.join(random.choice(string.ascii_letters + string.digits) for _ in range(32)).encode('utf8')).hexdigest()
- HMAC_SECRET = 'oKPlvWBXvTebRGiN'
- key = '536a784f76a4ec72951e3b16f3473d9e'
- def encrypt(raw):
- raw = raw + ':user' + HMAC_SECRET
- raw = compress(raw.encode("utf-8"))
- print('len_before_pad: ' + str(len(raw)))
- raw = pad(raw)
- cipher = AES.new(key)
- print('len_after_pad: ' + str(len(cipher.encrypt(raw))))
- raw = input('Input: ')
- encrypt(raw)
Add Comment
Please, Sign In to add comment