skillfed

libnacl

Python bindings for libsodium based on ctypes

libnacl v2.1.0 231.6K downloads/30d#9,083 on PyPI84
Permissive license Apache-2.0 AGING released

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 libnacl

uv

uv add libnacl

poetry

poetry add libnacl

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.6Programming Language :: Python :: 2.7Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Security :: Cryptography

Tags

libsodium python bindingsnacl cryptography libraryauthenticated encryption pythonpublic key cryptographydigital signatures pythonkey exchange protocolctypes crypto bindings
cryptographylibsodiumctypes-binding

More Cryptography packages