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) *  |
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 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) *  |
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) *  |
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) *  |
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) *  |
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) *  |
Date: 2010-09-06 03:19 |
Sounds like a good idea. frozensets for both. |
|
|
msg115689 - (view) |
Author: Éric Araujo (eric.araujo) *  |
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) *  |
Date: 2010-09-06 08:34 |
Implemented in py3k r84554. |
|
|
msg115727 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-09-06 18:43 |
Great, thank you! |
|
|