Skip to main content

PyNaCl: Python binding to the libsodium library

Latest Version https://codecov.io/github/pyca/pynacl/coverage.svg?branch=main Compatible Python Versions

PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library. These libraries have a stated goal of improving usability, security and speed. It supports Python 3.6+ as well as PyPy 3.

Features

  • Digital signatures

  • Secret-key encryption

  • Public-key encryption

  • Hashing and message authentication

  • Password based key derivation and password hashing

Changelog

Installation

Binary wheel install

PyNaCl ships as a binary wheel on macOS, Windows and Linux manylinux1 [1] , so all dependencies are included. Make sure you have an up-to-date pip and run:

$ pip install pynacl

Faster wheel build

You can define the environment variable LIBSODIUM_MAKE_ARGS to pass arguments to make and enable parallelization:

$ LIBSODIUM_MAKE_ARGS=-j4 pip install pynacl

Linux source build

PyNaCl relies on libsodium, a portable C library. A copy is bundled with PyNaCl so to install you can run:

$ pip install pynacl

If you’d prefer to use the version of libsodium provided by your distribution, you can disable the bundled copy during install by running:

$ SODIUM_INSTALL=system pip install pynacl

Changelog

1.5.0 (2022-01-07)

  • BACKWARDS INCOMPATIBLE: Removed support for Python 2.7 and Python 3.5.

  • BACKWARDS INCOMPATIBLE: We no longer distribute manylinux1 wheels.

  • Added manylinux2014, manylinux_2_24, musllinux, and macOS universal2 wheels (the latter supports macOS arm64).

  • Update libsodium to 1.0.18-stable (July 25, 2021 release).

  • Add inline type hints.

1.4.0 (2020-05-25)

  • Update libsodium to 1.0.18.

  • BACKWARDS INCOMPATIBLE: We no longer distribute 32-bit manylinux1 wheels. Continuing to produce them was a maintenance burden.

  • Added support for Python 3.8, and removed support for Python 3.4.

  • Add low level bindings for extracting the seed and the public key from crypto_sign_ed25519 secret key

  • Add low level bindings for deterministic random generation.

  • Add wheel and setuptools setup_requirements in setup.py (#485)

  • Fix checks on very slow builders (#481, #495)

  • Add low-level bindings to ed25519 arithmetic functions

  • Update low-level blake2b state implementation

  • Fix wrong short-input behavior of SealedBox.decrypt() (#517)

  • Raise CryptPrefixError exception instead of InvalidkeyError when trying to check a password against a verifier stored in a unknown format (#519)

  • Add support for minimal builds of libsodium. Trying to call functions not available in a minimal build will raise an UnavailableError exception. To compile a minimal build of the bundled libsodium, set the SODIUM_INSTALL_MINIMAL environment variable to any non-empty string (e.g. SODIUM_INSTALL_MINIMAL=1) for setup.

1.3.0 2018-09-26

  • Added support for Python 3.7.

  • Update libsodium to 1.0.16.

  • Run and test all code examples in PyNaCl docs through sphinx’s doctest builder.

  • Add low-level bindings for chacha20-poly1305 AEAD constructions.

  • Add low-level bindings for the chacha20-poly1305 secretstream constructions.

  • Add low-level bindings for ed25519ph pre-hashed signing construction.

  • Add low-level bindings for constant-time increment and addition on fixed-precision big integers represented as little-endian byte sequences.

  • Add low-level bindings for the ISO/IEC 7816-4 compatible padding API.

  • Add low-level bindings for libsodium’s crypto_kx… key exchange construction.

  • Set hypothesis deadline to None in tests/test_pwhash.py to avoid incorrect test failures on slower processor architectures. GitHub issue #370

1.2.1 - 2017-12-04

  • Update hypothesis minimum allowed version.

  • Infrastructure: add proper configuration for readthedocs builder runtime environment.

1.2.0 - 2017-11-01

  • Update libsodium to 1.0.15.

  • Infrastructure: add jenkins support for automatic build of manylinux1 binary wheels

  • Added support for SealedBox construction.

  • Added support for argon2i and argon2id password hashing constructs and restructured high-level password hashing implementation to expose the same interface for all hashers.

  • Added support for 128 bit siphashx24 variant of siphash24.

  • Added support for from_seed APIs for X25519 keypair generation.

  • Dropped support for Python 3.3.

1.1.2 - 2017-03-31

  • reorder link time library search path when using bundled libsodium

1.1.1 - 2017-03-15

  • Fixed a circular import bug in nacl.utils.

1.1.0 - 2017-03-14

  • Dropped support for Python 2.6.

  • Added shared_key() method on Box.

  • You can now pass None to nonce when encrypting with Box or SecretBox and it will automatically generate a random nonce.

  • Added support for siphash24.

  • Added support for blake2b.

  • Added support for scrypt.

  • Update libsodium to 1.0.11.

  • Default to the bundled libsodium when compiling.

  • All raised exceptions are defined mixing-in nacl.exceptions.CryptoError

1.0.1 - 2016-01-24

  • Fix an issue with absolute paths that prevented the creation of wheels.

1.0 - 2016-01-23

  • PyNaCl has been ported to use the new APIs available in cffi 1.0+. Due to this change we no longer support PyPy releases older than 2.6.

  • Python 3.2 support has been dropped.

  • Functions to convert between Ed25519 and Curve25519 keys have been added.

0.3.0 - 2015-03-04

  • The low-level API (nacl.c.*) has been changed to match the upstream NaCl C/C++ conventions (as well as those of other NaCl bindings). The order of arguments and return values has changed significantly. To avoid silent failures, nacl.c has been removed, and replaced with nacl.bindings (with the new argument ordering). If you have code which calls these functions (e.g. nacl.c.crypto_box_keypair()), you must review the new docstrings and update your code/imports to match the new conventions.

Metadata

Release files for PyNaCl 1.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyNaCl 1.5.0
File Size Uploaded
PyNaCl-1.5.0.tar.gz 3.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for PyNaCl 1.5.0
File
PyNaCl-1.5.0-cp36-abi3-win_amd64.whl CPython 3.6 abi3 Windows x86-64 Details
PyNaCl-1.5.0-cp36-abi3-win32.whl CPython 3.6 abi3 Windows x86-32 Details
PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_x86_64.whl CPython 3.6 abi3 Linux musl 1.1+ x86-64 Details
PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_aarch64.whl CPython 3.6 abi3 Linux musl 1.1+ ARM64 Details
PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 abi3 Linux glibc 2.17+ x86-64 Details
PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl CPython 3.6 abi3 Linux glibc 2.24+ x86-64, Linux glibc 2.17+ x86-64 Details
PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.6 abi3 Linux glibc 2.17+ ARM64 Details
PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl CPython 3.6 abi3 Linux glibc 2.24+ ARM64, Linux glibc 2.17+ ARM64 Details
PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl CPython 3.6 abi3 macOS 10.10+ universal2 (ARM64, x86-64) Details

Total release size: 9.2 MB

Release files / PyNaCl-1.5.0.tar.gz

Download URL PyNaCl-1.5.0.tar.gz
Size 3.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8ac7448f09ab85811607bdd21ec2464495ac8b7c66d146bf545b0f08fb9220ba
BLAKE2b-256 checksum
How to use checksums
a72227582568be639dfe22ddb3902225f91f2f17ceff88ce80e4db396c8986da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-win_amd64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-win_amd64.whl
Size 212.1 kB
Tags CPython 3.6 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
20f42270d27e1b6a29f54032090b972d97f0a1b0948cc52392041ef7831fee93
BLAKE2b-256 checksum
How to use checksums
5e22d3db169895faaf3e2eda892f005f433a62db2decbcfbc2f61e6517adfa87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-win32.whl

Download URL PyNaCl-1.5.0-cp36-abi3-win32.whl
Size 204.6 kB
Tags CPython 3.6 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
e46dae94e34b085175f8abb3b0aaa7da40767865ac82c928eeb9e57e1ea8a543
BLAKE2b-256 checksum
How to use checksums
252db7df6ddb0c2a33afdb358f8af6ea3b8c4d1196ca45497dd37a56f0c122be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_x86_64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_x86_64.whl
Size 1.1 MB
Tags CPython 3.6 Linux musl 1.1+ x86-64 abi3
SHA-256 checksum
How to use checksums
61f642bf2378713e2c2e1de73444a3778e5f0a38be6fee0fe532fe30060282ff
BLAKE2b-256 checksum
How to use checksums
fd1acc308a884bd299b651f1633acb978e8596c71c33ca85e9dc9fa33a5399b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_aarch64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_aarch64.whl
Size 663.8 kB
Tags CPython 3.6 Linux musl 1.1+ ARM64 abi3
SHA-256 checksum
How to use checksums
a422368fc821589c228f4c49438a368831cb5bbc0eab5ebe1d7fac9dded6567b
BLAKE2b-256 checksum
How to use checksums
3d85c262db650e86812585e2bc59e497a8f59948a005325a11bbbc9ecd3fe26b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.1 MB
Tags CPython 3.6 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
06b8f6fa7f5de8d5d2f7573fe8c863c051225a27b61e6860fd047b1775807858
BLAKE2b-256 checksum
How to use checksums
6628ca86676b69bf9f90e710571b67450508484388bfce09acf8a46f0b8c785f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Size 856.7 kB
Tags CPython 3.6 Linux glibc 2.17+ x86-64 Linux glibc 2.24+ x86-64 abi3
SHA-256 checksum
How to use checksums
0c84947a22519e013607c9be43706dd42513f9e6ae5d39d3613ca1e142fba44d
BLAKE2b-256 checksum
How to use checksums
ee87f1bb6a595f14a327e8285b9eb54d41fef76c585a0edef0a45f6fc95de125
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 680.1 kB
Tags CPython 3.6 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
a36d4a9dda1f19ce6e03c9a784a2921a4b726b02e1c736600ca9c22029474394
BLAKE2b-256 checksum
How to use checksums
5d7087a065c37cca41a75f2ce113a5a2c2aa7533be648b184ade58971b5f7ccc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl

Download URL PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Size 601.7 kB
Tags CPython 3.6 Linux glibc 2.17+ ARM64 Linux glibc 2.24+ ARM64 abi3
SHA-256 checksum
How to use checksums
52cb72a79269189d4e0dc537556f4740f7f0a9ec41c1322598799b0bdad4ef92
BLAKE2b-256 checksum
How to use checksums
59bbfddf10acd09637327a97ef89d2a9d621328850a72f1fdc8c08bdf72e385f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release files / PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl

Download URL PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl
Size 349.9 kB
Tags CPython 3.6 abi3 macOS 10.10+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
401002a4aaa07c9414132aaed7f6836ff98f59277a234704ff66878c2ee4a0d1
BLAKE2b-256 checksum
How to use checksums
ce750b8ede18506041c0bf23ac4d8e2971b4161cd6ce630b177d0a08eb0d8857
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

Release history Release notifications | RSS feed

1.6.1

27 release files

1.6.0

27 release files

This release

1.5.0 This release

10 release files

1.4.0

18 release files

1.3.0

21 release files

1.1.2

28 release files

1.1.1

16 release files

1.1.0

16 release files

1.0.1

16 release files

1.0

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page