parent
619e0f05e2
commit
f369e2fdac
20 changed files with 77 additions and 117 deletions
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
from Cryptodome import Random
|
||||
from Cryptodome.Cipher import AES
|
||||
|
||||
|
|
@ -10,10 +11,10 @@ key = bytes.fromhex("3aa925cb69eb613e2928f8a18279c78b1dca04541dfd064df2eda66b598
|
|||
|
||||
BLOCK_SIZE = 16
|
||||
|
||||
|
||||
class AESCipher(object):
|
||||
"""This class is compatible with crypto.createCipheriv('aes-256-cbc')"""
|
||||
"""This class is compatible with crypto.createCipheriv('aes-256-cbc')
|
||||
|
||||
"""
|
||||
def __init__(self, key=None):
|
||||
self.key = key
|
||||
|
||||
|
|
@ -32,10 +33,9 @@ class AESCipher(object):
|
|||
def decrypt(self, iv, enc_text):
|
||||
cipher = AES.new(self.key, AES.MODE_CBC, iv=iv)
|
||||
return self.unpad(cipher.decrypt(enc_text).decode("UTF-8"))
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
aes = AESCipher(key=key)
|
||||
iv, enc_text = aes.encrypt(plain_text)
|
||||
dec_text = aes.decrypt(iv, enc_text)
|
||||
print(dec_text)
|
||||
print(dec_text)
|
||||
Loading…
Add table
Add a link
Reference in a new issue