Skip to content
Bindings and examples for using low-level libsodium functionality in Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Bindings and examples for using low-level libsodium functionality in Python.

The ctype-bindings here are a slightly extended version of libnacl's, written by Thomas S Hatch and others. See for the original source code and higher-level bindings for Python. The ctype-bindings provided here have been merged into libnacl in September 2017, so to run the examples you can use either the binding-file provided here, or a recent release of libnacl (>= v1.6.0).

Libsodium is a modern C-library for encryption, decryption, signatures, password hashing and more, based on the algorithms in Daniel J. Bernstein's NaCl. While there are several interfaces to libsodium for Python, none seemed to provide access to libsodium's crypto_box_easy-functions (which differ from the NaCl crypto_box-functions in their use of padding bytes). Because I needed to interface with a C-application that uses crypto_box_easy, I provided bindings to these functions, and to a few other functions specific to libsodium, including:

I have added some Python-examples on how to use these functions to generate an Ed25519 keypair, to derive Curve25519 keys and use these to encrypt a message, and to decrypt an encrypted message (which consists of nonce and cipthertext).

To use the examples, you will need to have libsodium installed. See the installation guide for more information. On Ubuntu and other Debian-based Linux systems, you can simply do: sudo apt-get install libsodium-dev

December 2017, Levien van Zon (

You can’t perform that action at this time.