homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: hashlib : the names of the different hash algorithms
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: chaica_, eric.araujo, flox, gps, gregory.p.smith, rhettinger
Priority: normal Keywords: patch

Created on 2009年12月01日 14:04 by chaica_, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
algorithms_constant_attribute_in_hashlib_module.diff chaica_, 2009年12月01日 14:04
algorithms_constant_attribute_in_hashlib_module_update1.diff chaica_, 2009年12月02日 09:05 Patch for the hashlib module - update 1
Messages (13)
msg95857 - (view) Author: Carl Chenet (chaica_) Date: 2009年12月01日 14:04
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
msg95860 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009年12月01日 15:20
I guess you missed the quotes.
$ ./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'
msg95899 - (view) Author: Carl Chenet (chaica_) Date: 2009年12月02日 08:58
flox : You're right, sorry about that.
Here is a fixed patch.
msg95900 - (view) Author: Carl Chenet (chaica_) Date: 2009年12月02日 09:05
The fixed file :
algorithms_constant_attribute_in_hashlib_module_update1.diff
msg96854 - (view) Author: Carl Chenet (chaica_) Date: 2009年12月24日 12:07
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 :
 
 for __hashtype in ('md5', 'sha1',
'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.
msg99147 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010年02月10日 02:11
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
msg99155 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010年02月10日 05:21
I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)
msg100236 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010年03月01日 02:05
applied, it'll appear in 2.7 and 3.2.
r78528 and r78529.
msg115684 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010年09月06日 01:49
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.)
msg115688 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010年09月06日 03:19
Sounds like a good idea. frozensets for both.
msg115689 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010年09月06日 03:21
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).
msg115693 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2010年09月06日 08:34
Implemented in py3k r84554.
msg115727 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010年09月06日 18:43
Great, thank you!
History
Date User Action Args
2022年04月11日 14:56:55adminsetgithub: 51667
2010年09月06日 18:43:24eric.araujosetresolution: accepted -> fixed
messages: + msg115727
stage: needs patch -> resolved
2010年09月06日 08:34:47gregory.p.smithsetstatus: open -> closed

messages: + msg115693
2010年09月06日 03:21:27eric.araujosetstatus: closed -> open

messages: + msg115689
stage: needs patch
2010年09月06日 03:19:03gregory.p.smithsetmessages: + msg115688
2010年09月06日 01:49:46eric.araujosetnosy: + eric.araujo
messages: + msg115684
2010年03月01日 02:05:40gregory.p.smithsetstatus: open -> closed
resolution: accepted
messages: + msg100236
2010年03月01日 02:00:14gregory.p.smithsetassignee: rhettinger -> gregory.p.smith

nosy: + gregory.p.smith
2010年02月10日 09:28:14pitrousetnosy: + gps
2010年02月10日 05:21:25rhettingersetmessages: + msg99155
2010年02月10日 02:11:27rhettingersetmessages: + msg99147
2009年12月24日 12:07:59chaica_setmessages: + msg96854
2009年12月02日 09:05:53chaica_setfiles: + algorithms_constant_attribute_in_hashlib_module_update1.diff

messages: + msg95900
2009年12月02日 09:01:52chaica_setfiles: - algorithms_constant_value_in_hashlib_module.diff
2009年12月02日 08:58:45chaica_setfiles: + algorithms_constant_value_in_hashlib_module.diff

messages: + msg95899
2009年12月01日 17:24:29rhettingersetassignee: rhettinger

nosy: + rhettinger
2009年12月01日 15:20:31floxsetnosy: + flox
messages: + msg95860
2009年12月01日 14:04:27chaica_create

AltStyle によって変換されたページ (->オリジナル) /