Skip to main content

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.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

pysha3-1.0.2.tar.gz (829.2 kB view details)

Uploaded Source

Built Distributions

pysha3-1.0.2-cp36-cp36m-win_amd64.whl (35.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

pysha3-1.0.2-cp36-cp36m-win32.whl (22.2 kB view details)

Uploaded CPython 3.6m Windows x86

pysha3-1.0.2-cp36-cp36m-manylinux1_x86_64.whl (127.4 kB view details)

Uploaded CPython 3.6m

pysha3-1.0.2-cp36-cp36m-manylinux1_i686.whl (56.2 kB view details)

Uploaded CPython 3.6m

pysha3-1.0.2-cp35-cp35m-win_amd64.whl (35.9 kB view details)

Uploaded CPython 3.5m Windows x86-64

pysha3-1.0.2-cp35-cp35m-win32.whl (22.2 kB view details)

Uploaded CPython 3.5m Windows x86

pysha3-1.0.2-cp35-cp35m-manylinux1_x86_64.whl (127.3 kB view details)

Uploaded CPython 3.5m

pysha3-1.0.2-cp35-cp35m-manylinux1_i686.whl (56.0 kB view details)

Uploaded CPython 3.5m

pysha3-1.0.2-cp34-cp34m-win_amd64.whl (36.2 kB view details)

Uploaded CPython 3.4m Windows x86-64

pysha3-1.0.2-cp34-cp34m-win32.whl (21.8 kB view details)

Uploaded CPython 3.4m Windows x86

pysha3-1.0.2-cp34-cp34m-manylinux1_x86_64.whl (128.8 kB view details)

Uploaded CPython 3.4m

pysha3-1.0.2-cp34-cp34m-manylinux1_i686.whl (57.3 kB view details)

Uploaded CPython 3.4m

pysha3-1.0.2-cp33-cp33m-win_amd64.whl (36.2 kB view details)

Uploaded CPython 3.3m Windows x86-64

pysha3-1.0.2-cp33-cp33m-win32.whl (21.8 kB view details)

Uploaded CPython 3.3m Windows x86

pysha3-1.0.2-cp27-cp27mu-manylinux1_x86_64.whl (127.8 kB view details)

Uploaded CPython 2.7mu

pysha3-1.0.2-cp27-cp27mu-manylinux1_i686.whl (56.8 kB view details)

Uploaded CPython 2.7mu

pysha3-1.0.2-cp27-cp27m-win_amd64.whl (36.3 kB view details)

Uploaded CPython 2.7m Windows x86-64

pysha3-1.0.2-cp27-cp27m-win32.whl (20.1 kB view details)

Uploaded CPython 2.7m Windows x86

pysha3-1.0.2-cp27-cp27m-manylinux1_x86_64.whl (127.8 kB view details)

Uploaded CPython 2.7m

pysha3-1.0.2-cp27-cp27m-manylinux1_i686.whl (56.8 kB view details)

Uploaded CPython 2.7m

File details

Details for the file pysha3-1.0.2.tar.gz.

File metadata

  • Download URL: pysha3-1.0.2.tar.gz
  • Upload date:
  • Size: 829.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pysha3-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fe988e73f2ce6d947220624f04d467faf05f1bbdbc64b0a201296bb3af92739e
MD5 59cd2db7a9988c1f3f6aee40145e0c96
BLAKE2b-256 73bf978d424ac6c9076d73b8fdc8ab8ad46f98af0c34669d736b1d83c758afee

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0060a66be16665d90c432f55a0ba1f6480590cfb7d2ad389e688a399183474f0
MD5 fd125d5fa90182ea6047bcc6b25e8b14
BLAKE2b-256 b3a9108c8606e5e8a147afc5dcc06d730c1f8e07e189789ee8351321075d5832

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 cd5c961b603bd2e6c2b5ef9976f3238a561c58569945d4165efb9b9383b050ef
MD5 2f1c56c495c2aed4cf3a2b4dac43e03e
BLAKE2b-256 5a7682377ddfad120b823bc56f1a341c602b74bc64291b9c83226e1b1c6cef80

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c7c2adcc43836223680ebdf91f1d3373543dc32747c182c8ca2e02d1b69ce030
MD5 d397ef5a3332992fac7c29636f5cb7f1
BLAKE2b-256 322ab93e0c6d90c7c45e2fab35d7ef349e8c5bd7387a048e961b041fd9521556

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 386998ee83e313b6911327174e088021f9f2061cbfa1651b97629b761e9ef5c4
MD5 c18acefb7d2e0ddf5acb091f3c977883
BLAKE2b-256 acce060c3a422d8550da217e01c78d842286257f5faf1f0d93198121addd7a7e

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 684cb01d87ed6ff466c135f1c83e7e4042d0fc668fa20619f581e6add1d38d77
MD5 473beaa711dad78b3e392eb415cbc506
BLAKE2b-256 2892a11e9fd262f985a4af3902dee2473442ed1fa56b65b33294ecfdb1fa01ed

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 c93a2676e6588abcfaecb73eb14485c81c63b94fca2000a811a7b4fb5937b8e8
MD5 fc4a2abc34c606b741bebbb8fd7a7392
BLAKE2b-256 90586979db6b34746955cf6208bdeac257dc092635b372c92020268ab4e289c1

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4416f16b0f1605c25f627966f76873e432971824778b369bd9ce1bb63d6566d9
MD5 ddda02f0aa1d818d612689cfdc64dc9d
BLAKE2b-256 4ba57eb00630fa4dc9751464faab8b5908706a4190a3ab2a37b2c03cabb2c9a8

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 827b308dc025efe9b6b7bae36c2e09ed0118a81f792d888548188e97b9bf9a3d
MD5 c20ff9f71db0b3074a3355c61788ba71
BLAKE2b-256 d1d32048e03d1234b00aee002d1055f1ea3c94fd9bacde2529a40be2bc510838

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp34-cp34m-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp34-cp34m-win_amd64.whl
Algorithm Hash digest
SHA256 fd7e66999060d079e9c0e8893e78d8017dad4f59721f6fe0be6307cd32127a07
MD5 49de2e767a369d37b395f379cac82851
BLAKE2b-256 9e5c853501051166ad56decdd16598e073ee6720a3d25bd119919374880c2060

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp34-cp34m-win32.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp34-cp34m-win32.whl
Algorithm Hash digest
SHA256 9c778fa8b161dc9348dc5cc361e94d54aa5ff18413788f4641f6600d4893a608
MD5 3f8aefd422ab3d5ff24f701158ebd087
BLAKE2b-256 f1d231d0e05e60b08035b946536d96c5815075676f8fc68b4f83d76dabb8598a

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5ec8da7c5c70a53b5fa99094af3ba8d343955b212bc346a0d25f6ff75853999f
MD5 0cc6c414d37bad1820b594adfd3bb56c
BLAKE2b-256 2f925a82607ca24e298645941a5d5b8d69150980680ced2ec19840081181e2a7

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 11a2ba7a2e1d9669d0052fc8fb30f5661caed5512586ecbeeaf6bf9478ab5c48
MD5 fe42c5d0bf76b9dcbcc7712027114505
BLAKE2b-256 5f3b87365e95ae37adcee0ad4995b2603be5a3d306234b6474462d732688788a

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp33-cp33m-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp33-cp33m-win_amd64.whl
Algorithm Hash digest
SHA256 93abd775dac570cb9951c4e423bcb2bc6303a9d1dc0dc2b7afa2dd401d195b24
MD5 6d83fa20d1094fac33815da9040fc71b
BLAKE2b-256 b444e5450a410829d73d8859755214b4865cb094d7a946919434a8d20d300632

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp33-cp33m-win32.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp33-cp33m-win32.whl
Algorithm Hash digest
SHA256 571a246308a7b63f15f5aa9651f99cf30f2a6acba18eddf28f1510935968b603
MD5 bebdc2246195616f0c26d07d58d81bdd
BLAKE2b-256 a83081aa98538f91d039dc47191807bbdfadbc752df073cf624840e2677c7466

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 59111c08b8f34495575d12e5f2ce3bafb98bea470bc81e70c8b6df99aef0dd2f
MD5 7fbb76ed9b48c0a49280110784b130ce
BLAKE2b-256 c5bb7d793dfab828e01adb46e3c5976fe99acda12a954c728427cceb2acd7ee9

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 68c3a60a39f9179b263d29e221c1bd6e01353178b14323c39cc70593c30f21c5
MD5 b3317b93ad2208584b6ab29452b9d100
BLAKE2b-256 a7e7df1014623934b050ca6d371dd53ad650a4ab77975695808d6a9717424491

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 41be70b06c8775a9e4d4eeb52f2f6a3f356f17539a54eac61f43a29e42fd453d
MD5 021cdd2f47094b7688b48aa983973ffb
BLAKE2b-256 70c7793323eceb95761d64f80c482745ce91d0d57e5980478aa06703444330af

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 9fdd28884c5d0b4edfed269b12badfa07f1c89dbc5c9c66dd279833894a9896b
MD5 82f31e0e6b027b6bfeefd7896c6520f2
BLAKE2b-256 5c0b86b41f217d22f80cd09cee857d1089eb5a35aa50b1598fbd6b0258d3f5da

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f9046d59b3e72aa84f6dae83a040bd1184ebd7fef4e822d38186a8158c89e3cf
MD5 23bc371be3020a057055b55f1da95a7d
BLAKE2b-256 eabdf772ef2dc92494e5b78cb7c50f2a35a6d49153fd1ef5dd46a04b48462b43

See more details on using hashes here.

Provenance

File details

Details for the file pysha3-1.0.2-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pysha3-1.0.2-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6e6a84efb7856f5d760ee55cd2b446972cb7b835676065f6c4f694913ea8f8d9
MD5 db333231ef6814b31a8e7af47bcd94e9
BLAKE2b-256 51b03a1b1d1f827aee786e68f459ce599bc88e22739ea2a6072bd580d39190e0

See more details on using hashes here.

Provenance

Supported by

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