Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- from Crypto import Random
- from Crypto.Cipher import AES
- from Crypto.Util import Padding
- progLibMD5 = hashlib.md5("ProgLib".encode('utf-8'))
- print(progLibMD5.hexdigest())
- key = progLibMD5.digest()
- data = "Мама мыла раму"
- initial_vector = Random.new().read(AES.block_size)
- cipher = AES.new(key, AES.MODE_CBC, initial_vector)
- padding = Padding.pad(data.encode(), AES.block_size)
- encrypted = cipher.encrypt(padding)
- print(encrypted)
- cipher2 = AES.new(key, AES.MODE_CBC, initial_vector)
- padded = cipher2.decrypt(encrypted)
- decrypted = Padding.unpad(padded, AES.block_size)
- print(decrypted.decode())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement