revert formatting nostr

This commit is contained in:
dni ⚡ 2023-03-19 11:15:26 +01:00
parent bb1941445d
commit 4549d0af09
No known key found for this signature in database
GPG key ID: 886317704CC4E618
11 changed files with 48 additions and 71 deletions

View file

@ -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)