pip install pynacl
python
import nacl.utils
from nacl.public import PrivateKey, PublicKey, Box
private_key = PrivateKey.generate()
public_key = private_key.public_key
plaintext = b'Hello, World!'
nonce = nacl.utils.random(Box.NONCE_SIZE)
box = Box(private_key, public_key)
ciphertext = box.encrypt(plaintext, nonce)
box = Box(private_key, public_key)
decrypted_data = box.decrypt(ciphertext)