Skip to content

hashlib : the names of the different hash algorithms #51667

Closed

Description

@chaica
mannequin
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']

    Activity

    1. chaica commented on Dec 1, 2009

      chaicamannequin
      MannequinAuthor

      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

    2. added
      stdlib
      type-feature
      on Dec 1, 2009
    3. florentx commented on Dec 1, 2009

      florentxmannequin
      Mannequin

      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'
    4. self-assigned this
      on Dec 1, 2009
    5. chaica commented on Dec 2, 2009

      chaicamannequin
      MannequinAuthor

      flox : You're right, sorry about that.

      Here is a fixed patch.

    6. chaica commented on Dec 2, 2009

      chaicamannequin
      MannequinAuthor

      The fixed file :
      algorithms_constant_attribute_in_hashlib_module_update1.diff

    7. chaica commented on Dec 24, 2009

      chaicamannequin
      MannequinAuthor

      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.

    8. rhettinger commented on Feb 10, 2010

      @rhettinger
      Contributor

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

    9. rhettinger commented on Feb 10, 2010

      @rhettinger
      Contributor

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

    10. gpshead commented on Mar 1, 2010

      @gpshead
      Member

      applied, it'll appear in 2.7 and 3.2.

      r78528 and r78529.

    11. merwok commented on Sep 6, 2010

      @merwok
      Member

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

    12. gpshead commented on Sep 6, 2010

      @gpshead
      Member

      Sounds like a good idea. frozensets for both.

    13. merwok commented on Sep 6, 2010

      @merwok
      Member

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

    14. reopened this on Sep 6, 2010
    15. gpshead commented on Sep 6, 2010

      @gpshead
      Member

      Implemented in py3k r84554.

    16. merwok commented on Sep 6, 2010

      @merwok
      Member

      Great, thank you!

    17. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    stdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions