main_24.py 325 B

12345678910
  1. def pseudonymize_user_name(self, user_name: UserName) -> PseudoUserName:
  2. hasher = hashlib.sha256()
  3. hasher.update(user_name.encode('utf-8'))
  4. # salt
  5. hasher.update(b'\0')
  6. hasher.update(self.salt)
  7. pseudonymized = base64.b64encode(hasher.digest()).decode('utf-8')
  8. return PseudoUserName(pseudonymized)