Untitled
unknown
plain_text
a year ago
572 B
8
Indexable
def encryptpwd(plain_password):
# 📌 Générer un sel unique
SALT = os.urandom(16)
# 📌 Dériver la clé avec PBKDF2-HMAC-SHA512 (version native Python)
KEY = hashlib.pbkdf2_hmac('sha512', MASTER_KEY, SALT, 25000, dklen=32)
# 📌 Chiffrement AES-GCM
cipher = AES.new(KEY, AES.MODE_GCM)
ciphertext, tag = cipher.encrypt_and_digest(plain_password.encode())
# 📌 Encodage en base64 (format utilisé par pgAdmin)
encrypted_password = base64.b64encode(SALT + cipher.nonce + tag + ciphertext).decode()
return encrypted_passwordEditor is loading...
Leave a Comment