PyNaCl is a Python binding to the Networking and Cryptography (NaCl) library, providing cryptographic operations such as digital signatures, secret-key and public-key encryption, hashing, and password-based key derivation. The current version is 1.6.2, released on January 1, 2026. PyNaCl follows a regular release cadence, with updates approximately every 1-2 years.
pip install pynaclVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to generate a private key, derive the corresponding public key, create a PublicKeyBox for encryption, and encrypt and decrypt a message using PyNaCl.
Upgrade your Python installation to version 3.8 or higher.
Install the 'libsodium' library using your system's package manager or by following the installation instructions provided in the PyNaCl documentation.
Replace `PublicKeyBox` with `Box` in your code. The `Box` class provides equivalent functionality for public-key authenticated encryption. Consult the PyNaCl documentation for guidance on migrating from `PublicKeyBox` to `Box`.
Update your code to import 'Box' from 'nacl.public' instead of 'PublicKeyBox'.