pysodium
python libsodium wrapper
What it is and what it does
Pysodium exposes libsodium's cryptographic primitives to Python as a thin wrapper, providing direct access to authenticated encryption schemes (ChaCha20-Poly1305, AES-GCM variants), public-key cryptography (Curve25519), digital signatures (Ed25519), hashing (BLAKE2, SHA-512), and password hashing (Argon2, scrypt). It is designed for developers who want libsodium's battle-tested algorithms without the overhead of higher-level abstractions.
The package trades ease of use for directness: you work with raw bytes, manage nonces and keys yourself, and call low-level functions that map almost one-to-one to libsodium's C API. This makes it suitable for applications where you need fine-grained control over cryptographic operations, but it requires understanding the underlying primitives and their correct usage patterns.
Use it for:
- Encrypt and decrypt messages with authenticated encryption (ChaCha20-Poly1305, AES-GCM) for secure communication.
- Perform Diffie-Hellman key exchange using Curve25519 to establish shared secrets between parties.
- Sign and verify messages using Ed25519 for non-repudiation and authenticity verification.
- Hash passwords with Argon2 or scrypt for secure credential storage.
- Generate and verify message authentication codes (HMAC-SHA256/512) for data integrity.
- Stream encryption with ChaCha20 for large data or streaming scenarios.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Pysodium is a Python wrapper around libsodium that provides access to authenticated encryption, key exchange, signing, hashing, and password hashing functions.
Yes, if you have libsodium already installed or can install it on your system and need direct access to libsodium's cryptographic functions. The high install friction (external C dependency) and Beta status are real drawbacks, but the package is actively maintained, has no known vulnerabilities, and offers a permissive license. Consider it when you need low-level control over cryptographic primitives that higher-level libraries may not expose.
Install
pysodium on PyPI
pip
pip install pysodiumuv
uv add pysodiumpoetry
poetry add pysodiumInstalling pysodium
Before you install
Installation requires a pre-built libsodium library already present on the system, creating high friction for users unfamiliar with system-level dependency management. The package is actively maintained with recent commits, but the external compiled dependency is a significant barrier.
License in practice
BSD permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects that can satisfy the system dependency requirement.
Quickstart
import pysodium
# Generate a keypair for public-key encryption
pk, sk = pysodium.crypto_box_keypair()
# Encrypt a message
nonce = pysodium.randombytes(pysodium.crypto_box_NONCEBYTES)
ciphertext = pysodium.crypto_box(b'hello', nonce, pk, sk)
libsodium must be pre-installed on the system; pysodium is a wrapper and cannot function without it.
Verify before relying
- Whether libsodium installation is straightforward on all major platforms (Windows, macOS, Linux).
- Performance characteristics compared to pure-Python or alternative cryptography libraries.
- Whether the package is suitable for production use given its Beta development status.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 737 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 391,117/month — #7,018 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pysodium-0.7.18.tar.gz
Keywords: cryptography, API, NaCl, libsodium
Tags
More Security packages
Provides Python bindings to the FreeDesktop.org…
permissive · top 1,000 on PyPI
msalMSAL for Python handles OAuth2 and OpenID…
permissive · top 1,000 on PyPI
joserfcjoserfc implements JOSE standards (JWS, JWE,…
permissive · top 1,000 on PyPI
AuthlibAuthlib provides a complete implementation of…
permissive · top 1,000 on PyPI
argon2-cffi-bindingsProvides low-level CFFI bindings to the…
permissive · top 1,000 on PyPI
adalADAL for Python authenticates applications with…
permissive · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
libnaclPython bindings to libsodium's NaCl…
permissive · top 15,000 on PyPI
dilithium-pyA pure-Python implementation of ML-DSA (FIPS…
permissive · top 15,000 on PyPI
eciespyEncrypts and decrypts data using Elliptic Curve…
permissive · top 15,000 on PyPI
bcryptbcrypt provides modern password hashing using…
permissive · top 1,000 on PyPI
pyscryptA pure-Python implementation of the scrypt…
permissive · top 15,000 on PyPI
keyrings.cryptfileA keyring backend that stores passwords in an…
permissive · top 15,000 on PyPI
pycryptodomexPyCryptodomex provides low-level cryptographic…
permissive · top 1,000 on PyPI
pwdlibProvides a modern, easy-to-use wrapper for…
permissive · top 5,000 on PyPI
sslcryptoProvides AES, ECIES, and ECDSA cryptographic…
unclear · top 15,000 on PyPI