Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashlib : the names of the different hash algorithms #51667

Closed
chaica mannequin opened this issue Dec 1, 2009 · 13 comments
Closed

hashlib : the names of the different hash algorithms #51667

chaica mannequin opened this issue Dec 1, 2009 · 13 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@chaica
Copy link
Mannequin

chaica mannequin commented Dec 1, 2009

BPO 7418
Nosy @rhettinger, @gpshead, @merwok, @florentx
Files
  • algorithms_constant_attribute_in_hashlib_module.diff
  • algorithms_constant_attribute_in_hashlib_module_update1.diff: Patch for the hashlib module - update 1
  • 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 = <Date 2010-09-06.08:34:47.559>
    created_at = <Date 2009-12-01.14:04:27.195>
    labels = ['type-feature', 'library']
    title = 'hashlib : the names of the different hash algorithms'
    updated_at = <Date 2010-09-06.18:43:24.035>
    user = 'https://bugs.python.org/chaica'

    bugs.python.org fields:

    activity = <Date 2010-09-06.18:43:24.035>
    actor = 'eric.araujo'
    assignee = 'gregory.p.smith'
    closed = True
    closed_date = <Date 2010-09-06.08:34:47.559>
    closer = 'gregory.p.smith'
    components = ['Library (Lib)']
    creation = <Date 2009-12-01.14:04:27.195>
    creator = 'chaica_'
    dependencies = []
    files = ['15427', '15438']
    hgrepos = []
    issue_num = 7418
    keywords = ['patch']
    message_count = 13.0
    messages = ['95857', '95860', '95899', '95900', '96854', '99147', '99155', '100236', '115684', '115688', '115689', '115693', '115727']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'gregory.p.smith', 'gps', 'eric.araujo', 'flox', 'chaica_']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue7418'
    versions = ['Python 3.2']

    @chaica
    Copy link
    Mannequin Author

    chaica mannequin commented 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

    @chaica chaica mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Dec 1, 2009
    @florentx
    Copy link
    Mannequin

    florentx mannequin commented Dec 1, 2009

    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'

    @rhettinger rhettinger self-assigned this Dec 1, 2009
    @chaica
    Copy link
    Mannequin Author

    chaica mannequin commented Dec 2, 2009

    flox : You're right, sorry about that.

    Here is a fixed patch.

    @chaica
    Copy link
    Mannequin Author

    chaica mannequin commented Dec 2, 2009

    The fixed file :
    algorithms_constant_attribute_in_hashlib_module_update1.diff

    @chaica
    Copy link
    Mannequin Author

    chaica mannequin commented 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 :

        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.

    @rhettinger
    Copy link
    Contributor

    I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)

    1 similar comment
    @rhettinger
    Copy link
    Contributor

    I'll be taking a look at this patch during the sprints at Pycon. Will get back to you soonish :-)

    @gpshead gpshead assigned gpshead and unassigned rhettinger Mar 1, 2010
    @gpshead
    Copy link
    Member

    gpshead commented Mar 1, 2010

    applied, it'll appear in 2.7 and 3.2.

    r78528 and r78529.

    @gpshead gpshead closed this as completed Mar 1, 2010
    @merwok
    Copy link
    Member

    merwok commented 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
    Copy link
    Member

    gpshead commented Sep 6, 2010

    Sounds like a good idea. frozensets for both.

    @merwok
    Copy link
    Member

    merwok commented 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).

    @merwok merwok reopened this Sep 6, 2010
    @gpshead
    Copy link
    Member

    gpshead commented Sep 6, 2010

    Implemented in py3k r84554.

    @gpshead gpshead closed this as completed Sep 6, 2010
    @merwok
    Copy link
    Member

    merwok commented Sep 6, 2010

    Great, thank you!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants