Registry / auth-security / pynacl

pynacl

JSON →
library1.6.2pypypi✓ verified 27d ago

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 pynacl
INSTALL
IMPORT
SIG · PYNACL
P
pynacl
auth-securitypythonv1.6.2
Install
2.2s avg
Import
23ms
Disk
22MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.6.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.024s · 23.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.022s · 24MB
22MB installed
● package 22MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PublicKeyBox
from nacl.public import Box
from nacl.public import PublicKeyBox

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.

from nacl.public import PrivateKey, PublicKey, PublicKeyBox # Generate a private key private_key = PrivateKey.generate() # Derive the corresponding public key public_key = private_key.public_key # Create a PublicKeyBox for encryption box = PublicKeyBox(public_key) # Encrypt a message message = b"Secret message" encrypted = box.encrypt(message) # Decrypt the message decrypted = box.decrypt(encrypted) print(decrypted.decode())
Debug
Known issues
breakingPyNaCl 1.6.2 requires Python 3.8 or higher.
fix
Upgrade your Python installation to version 3.8 or higher.
affects: 1.6.2
gotchaEnsure that the 'libsodium' library is installed on your system, as PyNaCl depends on it for cryptographic operations.
fix
Install the 'libsodium' library using your system's package manager or by following the installation instructions provided in the PyNaCl documentation.
affects: 1.6.2
breakingThe class `PublicKeyBox` has been removed from the `nacl.public` module in PyNaCl versions 1.5.0 and later. This will result in an `ImportError`.
fix
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`.
affects: 1.6.2
breakingThe 'PublicKeyBox' class was removed from 'nacl.public' in PyNaCl version 1.6.0. If you are using PyNaCl 1.6.0 or later, use 'Box' instead.
fix
Update your code to import 'Box' from 'nacl.public' instead of 'PublicKeyBox'.
affects: 1.6.2
Upgrade
Version history
1.6.2latest on PyPI · released Jan 1, 2026
Audit
Dependencies
libsodiumrequiredPyNaCl is a Python binding to the libsodium library, which provides the underlying cryptographic operations.
Agent activity
29 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
pynacl — pip install pynacl · libregistry