Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Python wrapper for http://nacl.cace-project.eu/

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitignore
Octocat-spinner-32 README.md
Octocat-spinner-32 nacl.i
Octocat-spinner-32 setup.py
Octocat-spinner-32 test.py
README.md

PyNaCl: A Python Wrapper for NaCl

Overview

This is a simple wrapper for the NaCl cryptographic library (not Google's NativeClient). It currently wraps crypto_hash_sha256, crypto_hash_sha512, crypto_randombytes, and the crypto_box, crypto_sign, crypto_secretbox, crypto_stream, crypto_auth, crypto_scalarmult and crypto_onetimeauth default primitives.

API

The API is a very straightforward translation of NaCl's C API. Any function that returns an error code will raise ValueError if it returns anything but zero. Output arguments are returned, with keypair functions returning 2-tuples and everything else returning strings. The wrapper handles all padding, so you can just ignore that part of NaCl's documentation.

Eventually I'll translate the documentation over, but for now look at test.py and the NaCl documentation.

Installation

First, download NaCl. NaCl does not build with the -fPIC flag and therefore you must modify a file:

cd <location of extracted NaCl>
sed -i "s/$/ -fPIC/" okcompilers/c*

If you want the build status output printed to screen, you may also do:

sed -i "s/exec 2\?>.*//" do

You can then build NaCl with:

./do

Once NaCl is successfully built, you can clone pynacl and run:

export NACL_DIR=<location of extracted nacl directory>
python setup.py build
sudo python setup.py install

Testing

To run the tests, just run the script "test.py" in the distribution directory.

License

PyNaCl is released under version 2.0 of the Apache license.

Something went wrong with that request. Please try again.