1. PyCryptodome: 2. cryptography: python import nacl.utils from nacl.public import PrivateKey, PublicKey, Box alice_private_key = PrivateKey.generate() alice_public_key = alice_private_key.public_key bob_private_key = PrivateKey.generate() bob_public_key = bob_private_key.public_key message = b"Hello, Bob!" encrypted_message = Box(alice_private_key, bob_public_key).encrypt(message) signature = alice_private_key.sign(encrypted_message) decrypted_message = Box(bob_private_key, alice_public_key).decrypt(encrypted_message) verified = bob_public_key.verify(encrypted_message, signature)


上一篇:
下一篇:
切换中文