def decrypt(self, signature, encrypted_msg, host):
'''
Decrypt received message. If this message can't be verified then
return None.
Args:
encrypted_msg (bytes) Encrypted message from a user in the chat
Return:
None if message isn't verified else decrypted message
'''
user_id = self._client.host2user_id[host]
decrypted_msg = self._keypair.decrypt(encrypted_msg)
decrypted_msg_hash = SHA256.new(decrypted_msg).digest()
if self.verify(decrypted_msg_hash, signature, user_id):
return decrypted_msg.decode('utf-8')
评论列表
文章目录