You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hashlib : the names of the different hash algorithms #51667
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/gpshead'closed_at=<Date2010-09-06.08:34:47.559>created_at=<Date2009-12-01.14:04:27.195>labels= ['type-feature', 'library']
title='hashlib : the names of the different hash algorithms'updated_at=<Date2010-09-06.18:43:24.035>user='https://bugs.python.org/chaica'
$ ./python foo.py
Traceback (most recent call last):
File "foo.py", line 2, in <module>from hashlib import*TypeError: attribute name must be string, not 'tuple'
The fixed file :
algorithms_constant_attribute_in_hashlib_module_update1.diff
chaica commented on Dec 24, 2009
chaicamannequin
MannequinAuthor
More actions
Hi,
Maybe you have some ideas on this patch? I think it could be a nice
feature e.g in my app I need to support every hash algorithms available
so with optparse module it is possible to write something like :
Activity
chaica commentedon Dec 1, 2009
Hi,
The hashlib module could provide a tuple offering the names of the
different hash algorithms which are guaranteed to be supported.
The expected result:
>>> import hashlib >>> hashlib.algorithms ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')Here is a patch to do so. It also provides an update for the hashlib
documentation and a test case.
Bye,
Carl Chenet
florentx commentedon Dec 1, 2009
I guess you missed the quotes.
chaica commentedon Dec 2, 2009
flox : You're right, sorry about that.
Here is a fixed patch.
chaica commentedon Dec 2, 2009
The fixed file :
algorithms_constant_attribute_in_hashlib_module_update1.diff
chaica commentedon Dec 24, 2009
Hi,
Maybe you have some ideas on this patch? I think it could be a nice
feature e.g in my app I need to support every hash algorithms available
so with optparse module it is possible to write something like :
'sha224','sha256','sha384','sha512'):
__parser.add_option('--{}'.format(__hashtype), dest='hashtype',
action='store_const', const='{}'.format(__hashtype),
help='use the {} hash algorithm type'.format(__hashtype))
__options, _ = __parser.parse_args()
And it would be better if this tuple could be provided by the hashlib
module itself, making the code more evolutive.
rhettinger commentedon Feb 10, 2010
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
rhettinger commentedon Feb 10, 2010
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
gpshead commentedon Mar 1, 2010
applied, it'll appear in 2.7 and 3.2.
r78528 and r78529.
merwok commentedon Sep 6, 2010
Could the module also grow an attribute listing all available algos, or non-guaranteed algos? (Please tell me if I should open a new report.)
gpshead commentedon Sep 6, 2010
Sounds like a good idea. frozensets for both.
merwok commentedon Sep 6, 2010
Thanks for the reply. Reopening.
I cannot propose a patch since I don’t know how to introspect OpenSSL (or how to write C, for that matter).
gpshead commentedon Sep 6, 2010
Implemented in py3k r84554.
merwok commentedon Sep 6, 2010
Great, thank you!