Bindings and examples for using low-level libsodium functionality in Python.
The ctype-bindings here are a slightly extended version of libnacl's
__init__.py, written by
Thomas S Hatch and others. See https://github.com/saltstack/libnacl 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:
- Conversion of Ed25519 keypairs to Curve25519
- Generating keys from seed, and generating public keys from private keys.
- Detached signatures and verification
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 (https://github.com/lvzon)