This commit is contained in:
2024-03-08 13:50:04 +08:00
parent bdb44e45c9
commit 7dffd231bb
10 changed files with 359 additions and 0 deletions

14
crypto.py Normal file
View File

@@ -0,0 +1,14 @@
from Crypto.Cipher import AES
from hashlib import sha256
from base64 import b64decode
def decrypt(encrypted: str | bytes,
key: str | bytes = 'zG2nSeEfSHfvTCHy5LCcqtBbQehKNLXn') -> bytes:
if isinstance(key, str):
key = key.encode()
ekey = sha256(key).digest()
iv = b'\0' * 16
aes = AES.new(ekey, AES.MODE_CBC, iv)
data = aes.decrypt(b64decode(encrypted))
return data[0:len(data) - ord(chr(data[len(data) - 1]))]