libnacl
Python bindings for libsodium based on ctypes
What it is and what it does
Libnacl is a Python wrapper around libsodium (Daniel J. Bernstein's NaCl cryptography library) that exposes both low-level ctypes bindings and high-level Pythonic encryption classes. It provides authenticated encryption, digital signatures, key exchange, and other cryptographic primitives without requiring compilation of the binding itself—only libsodium must be present on the system.
The package is designed for portability and ease of distribution; a single binding file can be embedded directly into projects. It supports Python 3.4 through 3.11 and is classified as production-stable. The library has no Python runtime dependencies, making it lightweight to install, though you must have libsodium available as a system library.
Use it for:
- Building encrypted messaging systems with authenticated encryption (SecretBox) for confidentiality and integrity.
- Implementing digital signature verification for message authentication and non-repudiation.
- Establishing secure key exchange between parties using public-key cryptography primitives.
- Embedding cryptographic bindings directly into standalone Python applications without external package dependencies.
- Prototyping or deploying cryptographic protocols that require low-level access to NaCl functions.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python bindings to libsodium's NaCl cryptography library, providing both low-level ctypes access and high-level encryption classes for authenticated encryption, signing, and key exchange.
Yes, if you need NaCl cryptography and libsodium is already available on your system. The package is stable, has no Python dependencies, and offers both low-level and high-level APIs. However, the aging maintenance status (last release 2023, infrequent commits) means you should verify that libsodium availability and the package's feature set meet your needs before adopting it for new projects; consider whether a more actively maintained alternative better suits your timeline.
Install
libnacl on PyPI
pip
pip install libnacluv
uv add libnaclpoetry
poetry add libnaclInstalling libnacl
Before you install
Low friction install with no Python runtime dependencies; the package requires libsodium to be available on the system but does not compile itself. Last release was in 2023, and the repository remains active with a recent commit in 2026, though the project is aging without frequent updates.
License in practice
Apache-2.0 is a permissive license that allows commercial use, modification, and distribution with minimal restrictions; you may use this package in proprietary projects provided you include a copy of the license.
Quickstart
pip install libnacl
import libnacl
import libnacl.utils
# Generate a keypair for public-key encryption
pk, sk = libnacl.utils.salsa_key()
# Or use high-level classes
from libnacl.public import SecretKey
secret_key = SecretKey()
libsodium must be installed and available on your system; libnacl is a ctypes wrapper and does not bundle or compile the underlying C library.
Verify before relying
- Whether libsodium is typically pre-installed on major OS distributions or requires separate installation steps.
- Current maintenance cadence and whether the aging status reflects intentional stability or lack of active development.
- Performance characteristics compared to other libsodium bindings for Python.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.4,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 1,104 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 231,587/month — #9,083 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: libnacl-2.1.0-py3-none-any.whl
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
pysodiumPysodium is a Python wrapper around libsodium…
permissive · top 15,000 on PyPI
pure25519Pure-Python implementation of Curve25519 and…
permissive · top 15,000 on PyPI
securesystemslibSecuresystemslib provides a cryptography…
permissive · top 5,000 on PyPI
endesiveEndesive signs and verifies digital signatures…
unclear · top 15,000 on PyPI
fernetA pure Python implementation of the Fernet…
permissive · top 15,000 on PyPI
gmsslPure-Python implementation of SM2, SM3, and SM4…
permissive · top 15,000 on PyPI
PGPy13PGPy13 is a Python library for OpenPGP…
permissive · top 15,000 on PyPI
libthumborlibthumbor generates encrypted URLs for the…
permissive · top 15,000 on PyPI