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