Skip to content

Commit 2fedd04

Browse files
fix for stable reversible pseudonym
1 parent e87ed97 commit 2fedd04

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

app/services/pseudonym_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ def encode_pseudonym(self, pseudonym: str) -> str:
7979
Encode the personal ID using AES encryption in CBC mode with PKCS7 padding.
8080
"""
8181
try:
82-
iv = get_random_bytes(AES.block_size)
82+
iv_input = hashlib.sha256("|".join(pseudonym.split('|')[:-2]).encode('utf-8')).digest()
83+
iv = iv_input[:AES.block_size]
8384
message = f"{pseudonym}".encode('utf-8')
8485
cipher = AES.new(self.__aes_key, AES.MODE_GCM, iv)
8586
ciphertext = cipher.encrypt(pad(message, AES.block_size))

0 commit comments

Comments
 (0)