SHA-3 (Keccak) for Python 2.7 - 3.5
Project description
SHA-3 wrapper (keccak) for Python. The package is a wrapper around the optimized Keccak Code Package, https://github.com/gvanas/KeccakCodePackage .
The module is a standalone version of my SHA-3 module from Python 3.6 (currently under development). The code in sha3module.c has been modified to be compatible with Python 2.7 to 3.5. Python 2.6 and earlier are not supported.
Updates since pysha 0.3
pysha3 1.0 is not compatible with pysha3 0.3!
pysha3 < 1.0 used the old Keccak implementation. During the finalization of SHA3, NIST changed the delimiter suffix from 0x01 to 0x06. The Keccak sponge function stayed the same. pysha3 1.0 provides the previous Keccak hash, too.
Platforms
pysha3 has been successfully tested on several platforms:
Linux (GCC, clang) on X86, X86_64 and ARMv6 (little endian)
Windows (VS 2008, VS 2010, VS2015) on X86 and X86_64
Usage
The sha3 module contains several constructors for hash objects with a PEP 247 compatible interface. The module provides SHA3, SHAKE and Keccak:
sha3_228(), sha3_256(), sha3_384(), and sha3_512()
shake_128(), shake_256()
keccak_228(), keccak_256(), keccak_384(), and keccak_512()
The sha3 module monkey patches the hashlib module . The monkey patch is automatically activated with the first import of the sha3 module. The hashlib module of Python 3.6 will support the four SHA-3 algorithms and the two SHAKE algorithms on all platforms. Therefore you shouldn’t use the sha3 module directly and rather go through the hashlib interface:
>>> import sys >>> import hashlib >>> if sys.version_info < (3, 6): ... import sha3 >>> s = hashlib.sha3_512() >>> s.name 'sha3_512' >>> s.digest_size 64 >>> s.update(b"data") >>> s.hexdigest() 'ceca4daf960c2bbfb4a9edaca9b8137a801b65bae377e0f534ef9141c8684c0fedc1768d1afde9766572846c42b935f61177eaf97d355fa8dc2bca3fecfa754d' >>> s = hashlib.shake_256() >>> s.update(b"data") >>> s.hexdigest(4) 'c73dbed8' >>> s.hexdigest(8) 'c73dbed8527f5ae0' >>> s.hexdigest(16) 'c73dbed8527f5ae0568679f30ecc5cb6' >>> import sha3 >>> k = sha3.keccak_512() >>> k.update(b"data") >>> k.hexdigest() '1065aceeded3a5e4412e2187e919bffeadf815f5bd73d37fe00d384fe29f55f08462fdabe1007b993ce5b8119630e7db93101d9425d6e352e22ffe3dcb56b825'
Changelog
pysha3 1.0b1
Release date: 01-May-2016
Update backend to use the latest Keccak Code Package. pysha3 now implements the official NIST standard. The old Keccak hashes are available with keccak prefix.
Add SHAKE support.
All sha3, shake and keccak variants are separate types instead of factory functions that return the same type.
Drop Python 2.6 and Python 3.0 to 3.3 support.
Fix typo that disabled threading optimization.
Add vector files for additional tests.
Add experimental HMAC support based on examples from http://wolfgang-ehrhardt.de/hmac-sha3-testvectors.html .
Test hashing of unaligned data.
Add ISO C11 memset_s() function as _Py_memset_s() in order to securely wipe memory that holds sensitive data. The page https://www.securecoding.cert.org/confluence/display/seccode/MSC06-C.+Be+aware+of+compiler+optimization+when+dealing+with+sensitive+data explains the motivation for memset_s().
Add tox support.
Add Travis and appveyor integration.
Add _capacity_bits, _rate_bits and _suffix attributes for diagnostic purposes.
pysha3 0.3
Release date: 14-Oct-2012
Fix 64bit big endian support
Add workaround for alignment error on 64bit SPARC machine by using the opt32 implementation.
block_size now returns NotImplemented to prevent users from using pysha3 with the hmac module.
pysha3 0.2.2
Release date: 07-Oct-2012
Re-add brg_endian.h to fix issue on Solaris (big endian platform)
pysha3 0.2.1
Release date: 06-Oct-2012
Fix MANIFEST.in to include Makefile and tests.py
Add setup.py test command with hack for inplace builds
Enhance README.txt and fixed its markup
pysha3 0.2
Release date: 06-Oct-2012
Change directory struct to use the same directory layout as Python 3.4.
Remove C++ comments from Keccak sources for ANSI C compatibility.
Declare all Keccak functions and globals as static to avoid name clashes.
Remove alias sha3() for sha3_512().
Add block_size attribute. Keccak has a internal sponge size of 1600 bits.
Release GIL around SHA3_update() calls.
Monkey patch the hashlib module to support, e.g. hashlib.sha3_512() and hashlib.new(“sha3_512”)
Release GIL around SHA3_update() when the data exceeds a certain size.
Fix build on platforms with an unsigned 64bit integer type (uint64_t). The module falls back to 32bit implementation of Keccak with interleave tables.
pysha3 0.1
Release date: 04-Oct-2012
first release
based on KeccakReferenceAndOptimized-3.2.zip
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pysha3-1.0b1.tar.gz
.
File metadata
- Download URL: pysha3-1.0b1.tar.gz
- Upload date:
- Size: 828.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e9c1d9eab3ad18e3c715ae3550229c88011a97959feb96ad1747031ecfb0997 |
|
MD5 | d29053c7f89ec3318876867135755a25 |
|
BLAKE2b-256 | e5dbef362b1bc6502dec6fa1e2882335ea03692bcd29014e90a346527984a933 |
File details
Details for the file pysha3-1.0b1-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 35.8 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b59961a333cafd1a525bc24a6d748e8cc29e05451d3c4ef7f614df66cdd19120 |
|
MD5 | 37d2cc653ea7cd4d2121d0adc1999670 |
|
BLAKE2b-256 | d8519d0384e487ea6d835835870588edb75cc180b0a7d87476c9d26f59c97fe6 |
File details
Details for the file pysha3-1.0b1-cp35-cp35m-win32.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp35-cp35m-win32.whl
- Upload date:
- Size: 22.0 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4d18ef4a91814c73db1165cc1c0ec0eda9e83c0efcf2e972d4672a17111558 |
|
MD5 | 5726649c242a23315450451cca1f8b18 |
|
BLAKE2b-256 | c7b339c638e661e85faa14292bb086e6740e36c78eb4cde48f006348ed6e4d51 |
File details
Details for the file pysha3-1.0b1-cp34-cp34m-win_amd64.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp34-cp34m-win_amd64.whl
- Upload date:
- Size: 35.8 kB
- Tags: CPython 3.4m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 074fdf861f58f9f2f74a0590c21b13ee10f4f25994a8c0e20579ecf42ec16ba0 |
|
MD5 | c3b583d3418357a68115a5801b3b6aff |
|
BLAKE2b-256 | 97df4493e7b4d3779bd238cce53a50c538917bb99daf9e5cff175e3b6814dd42 |
File details
Details for the file pysha3-1.0b1-cp34-cp34m-win32.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp34-cp34m-win32.whl
- Upload date:
- Size: 21.3 kB
- Tags: CPython 3.4m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b28c9587f9fb80052f005ff4cd6d746cf56704fa44a77e51803e60ef4463d4ae |
|
MD5 | 1a08501694bf3d3c0b6850e78ebbe239 |
|
BLAKE2b-256 | 736abc331ef775d74302da5b3c57b3b20596617e2129daaa484a517484b6fa9a |
File details
Details for the file pysha3-1.0b1-cp33-none-win_amd64.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp33-none-win_amd64.whl
- Upload date:
- Size: 35.8 kB
- Tags: CPython 3.3, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc20eb5d34e222e37a71466ad3de50f860301659337fb560ab7813d3baf97cd1 |
|
MD5 | 4ace40d4351cd5c614c869de166baca5 |
|
BLAKE2b-256 | 58640fdc7137aab0c6703dbfa969359582756f98221da65f0f2164cd43c3ecc8 |
File details
Details for the file pysha3-1.0b1-cp33-none-win32.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp33-none-win32.whl
- Upload date:
- Size: 21.3 kB
- Tags: CPython 3.3, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9803d5189808f8da4dcbd87b26cc303ebbee7676e20ef13f24b8f9c5af05b7ce |
|
MD5 | 13b2b6baf82bad77d208eca285a6df31 |
|
BLAKE2b-256 | de6aac38b2512e6f7ba52151d69884eb8381f9f812a81b4d160c2dce09de327e |
File details
Details for the file pysha3-1.0b1-cp27-none-win32.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp27-none-win32.whl
- Upload date:
- Size: 19.7 kB
- Tags: CPython 2.7, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44e854c6567143b97e6f6e1e6d6e9bb4fbdc100a6518145ac53e633d7555c126 |
|
MD5 | 5799d261a4987e59885a0405d7614a75 |
|
BLAKE2b-256 | 9a06e183c0228fb49344f56ab3b3a78b43fdf9f0a989ac4b30011e4d6dfa6598 |
File details
Details for the file pysha3-1.0b1-cp27-cp27m-win_amd64.whl
.
File metadata
- Download URL: pysha3-1.0b1-cp27-cp27m-win_amd64.whl
- Upload date:
- Size: 35.9 kB
- Tags: CPython 2.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0845a9bff4cb710eaead0dc4b621e4b1641d1c4aae11c66ec67c9d83cbacd1cf |
|
MD5 | 9624291224ac2002a2765a12d284b27f |
|
BLAKE2b-256 | 41e4b173796fdc1207041eb74d47748382c722700ccdb142624e02e7111d5b69 |