tiran / pysha3

Backport of hashlib.sha3 for 2.7 to 3.5

Home Page:https://docs.python.org/3/library/hashlib.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unsupported hash type sha3_256

fastchain opened this issue · comments

Hi,
After installation according the manual I get this with new() function:

Python 2.7.16 (default, Mar 11 2019, 18:59:25) 
[GCC 8.2.1 20181127] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> 
>>> import sha3
>>> hashlib.new('sha3_256')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/hashlib.py", line 130, in __hash_new
    return __get_builtin_constructor(name)(string)
  File "/usr/lib64/python2.7/hashlib.py", line 97, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha3_256
>>> hashlib
<module 'hashlib' from '/usr/lib64/python2.7/hashlib.pyc'>
>>> dir(hashlib)
['__all__', '__builtins__', '__doc__', '__file__', '__get_builtin_constructor', '__name__', '__package__', '_hashlib', 'algorithms', 'algorithms_available', 'algorithms_guaranteed', 'md5', 'new', 'pbkdf2_hmac', 'sha1', 'sha224', 'sha256', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'shake_128', 'shake_256']
>>> dir(hashlib.algorithms)
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']
>>> hashlib.algorithms
('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
>>> hashlib.algorithms_available
set(['sha3-512', 'shake128', 'sha3-384', 'sha3-256', 'sha512-224', 'blake2s256', 'shake256', 'blake2b512', 'md4', 'md5', 'sha1', 'sha224', 'sm3', 'sha512-256', 'mdc2', 'sha3-224', 'sha384', 'md5-sha1', 'sha256', 'sha512', 'ripemd160', 'whirlpool'])
>>> 

pysha3 doesn't patch hashlib.new. It only adds hashlib.sha3_256. The new function doesn't support plugging.