skillfed

pysodium

python libsodium wrapper

pysodium v0.7.18 391.1K downloads/30d#7,018 on PyPI137
Permissive license BSD Active released

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 pysodium

uv

uv add pysodium

poetry

poetry add pysodium

Installing 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

Development Status :: 4 - BetaLicense :: OSI Approved :: BSD LicenseTopic :: SecurityTopic :: Security :: Cryptography

Tags

libsodium python wrapperauthenticated encryption pythonchacha20poly1305 pythonnacl cryptography librarycurve25519 key exchangeblake2 hashing pythonargon2 password hashing
cryptographysystem-dependencylow-level-api

More Security packages