Skip to main content

SHA-3 (Keccak) for Python 3.9 - 3.13

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_224(), sha3_256(), sha3_384(), and sha3_512()

  • shake_128(), shake_256()

  • keccak_224(), 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.0.3-dev

Unreleased

  • Fix typo in documentation (sha3_228 -> sha3_224)

  • Add manylinux1 builder

  • Don’t use privat pystrhex.h

pysha3 1.0.2

Release: 05-Feb-2017

  • Rename internal C extension to _pysha3 to avoild conflict with Python 3.6’ _sha3 extension.

pysha3 1.0.1

Release: 24-Jan-2017

  • Fix github.org -> github.com (Pi Delport)

  • Fix endianness checks for Python 2 (William Grant)

  • Fix changelog, the Christmas release was 1.0.0, not 1.1.0

pysha3 1.0.0

Release date: 24-Dec-2016

  • Synchronize with Python 3.6.0 release

  • Move all backport related additions to backport.inc

  • Fix flake8 violations

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safe_pysha3-1.0.5.tar.gz (827.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

safe_pysha3-1.0.5-cp313-cp313-musllinux_1_2_x86_64.whl (367.2 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

safe_pysha3-1.0.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (190.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

safe_pysha3-1.0.5-cp312-cp312-musllinux_1_2_x86_64.whl (184.5 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

safe_pysha3-1.0.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (190.4 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

safe_pysha3-1.0.5-cp311-cp311-musllinux_1_2_x86_64.whl (184.2 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

safe_pysha3-1.0.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (190.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

safe_pysha3-1.0.5-cp310-cp310-musllinux_1_2_x86_64.whl (182.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

safe_pysha3-1.0.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (188.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

safe_pysha3-1.0.5-cp39-cp39-musllinux_1_2_x86_64.whl (182.7 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

safe_pysha3-1.0.5-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (188.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file safe_pysha3-1.0.5.tar.gz.

File metadata

  • Download URL: safe_pysha3-1.0.5.tar.gz
  • Upload date:
  • Size: 827.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for safe_pysha3-1.0.5.tar.gz
Algorithm Hash digest
SHA256 88ceaad6af4b6bdecd2f54b31ad0e5e5e210d4f5ecabb1bd1fd3539ad61b7bf1
MD5 25aadfbf890a47af1626f2b9bc7cdbd6
BLAKE2b-256 a427a942b8a95b97c5fb8d27d3b86b8d269546cf21f87d9ec6b44c3702ce67cc

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fa37d5d6138d5dd01d1035dba019b7525ad7c55669ded4524f589cddd13ea13b
MD5 d759059bd2b4a8c282053cb55c40218f
BLAKE2b-256 e6a6e134e353a4961090caf4f429044b845584fe11d2217960a2549943ef01ea

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2019065f1b7d3db37cc52d091c9d5526d5d36a3e1b9efcf0b345c24e03755bff
MD5 ca8a0d2204704b68716104721c0a7c24
BLAKE2b-256 3ada7e1f252e6984f4b82393e4e083d3a48806e8a7225651559e50dec0000c68

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9a0cb37252a8767992f354d7d2af2ef04730032927eb6af2057e71744c741287
MD5 68d7e889211bcc9c70804f302fd6e188
BLAKE2b-256 da6a25e926ab9c8d714be2ee1d40f45eb425f438c968d97ede69a7cbff054094

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d137a73029c6c5a1db5791ae9fa62373827eee5226d19b79b836a6cf48b6b197
MD5 6ba253fef3702fe8a2c23328de565da9
BLAKE2b-256 bd598d7f64a3eb6ebbde248cc0347a67d7825e2ba6edfa2bd180ebdfb599b3c5

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4048005b764861f36eed98a83fb04268c972b6100fe530303999ff6fce744e64
MD5 c6ed4cc423a364bbc2e13cf2fc775fa7
BLAKE2b-256 c0ad30e8abf4535b0ed4f36eea451534f61adb1012226d7a36c1e1ed970717f0

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4505f4b3ce327a8b02299e48b55c32094ed15c63f83e8d9477ebe91e8777fc8f
MD5 f097cea2b343b08cdaa1ee7b328795bf
BLAKE2b-256 fc8060f78a39693d5d38440d1e71f117f0131d668bfa42988ba23bcdd45f66ac

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 dbdc2f048fa48b660d26eb6eb897eec4e250d01219ae20cf5b1f8f8682194a41
MD5 10425bc5d549a63fdb7a8813bc37d305
BLAKE2b-256 82b0de13e2471bb528cfb023dfeacc24cb354ec45f8f86e5a4d3dba93756ccdb

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3d15b9b8e25c47dcf68857660b48c7bfb540b8aaaa4158651402f19ef047dff7
MD5 e9498a154d813e581ccade1d230f30e2
BLAKE2b-256 2f486ca5f2502092b99dd5de5f3ee9ff2e51b4f9c56387bf0a4125dfd44a70b0

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c8659d086c981eab422fe957bc6476cefdf6e93efed5599a3826d78f1a60f789
MD5 f5ecba22a26fbdf8e21ac7d5baa2e5fd
BLAKE2b-256 9f28e754502d62e61ce51d58ceeca40c02277c47db0ced082f5f4596dddd083f

See more details on using hashes here.

File details

Details for the file safe_pysha3-1.0.5-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for safe_pysha3-1.0.5-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 457ac10024e74aaaeeb373a6601ed06dff2b28ea66061ee8029a2a496703c6f7
MD5 9c716e47e686c2d8253245afd8df9c7c
BLAKE2b-256 1350a29eb8f67512323169f25120f101e7eaed5fa612d7b21f21884a8400b4f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page