Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2b7fd775b3
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (42 sloc) 1.58 kb

python-sha3 (0.1 beta)

October 3, 2012

This module implements SHA-3 (also known as Keccak) with a hashlib-like interface.

The module is written as a Python C extension on top of the reference implementation. This yields better performance than the pure Python implementation that is available on the Keccak website.

Sample usage:

import sha3
s = sha3.SHA3512() # also 224, 256, 384, 512
                   # also exposed as the function sha3.sha3_512(...)
print s.hexdigest()

Importing the sha3 module will also add the new modules to hashlib.

>>> import hashlib
>>> import sha3
>>> hashlib.sha3_512('foo')
<sha3.SHA3512 object at 0x7fcd0fcb7590>


python build

This will require a C compiler, as usual, and also the Python development headers.

Optionally, if you want to build a debian package:

debuild -d -us -uc


The test/ directory contains a bunch of unit tests. By convention the runnable unit tests have a name that begins with test_, such as the test/ suite. You can run all the tests with nosetests:

$ nosetests test/
Ran 1088 tests in 0.155s


While reference Keccak is tweakable and can hash bit strings, this module has the same API as the python hashlib module and work on bytes only.

The current implementation most likely has a bug or two, though the unit test coverage is fairly extensive.

More Information

Please refer to the Keccak website for more information:

Jump to Line
Something went wrong with that request. Please try again.