Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e6390a15
Commit
e6390a15
authored
Mar 01, 2010
by
Gregory P. Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds the hashlib.algorithms attribute. See issue7418.
parent
9e5d1327
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
1 deletion
+17
-1
Doc/library/hashlib.rst
Doc/library/hashlib.rst
+9
-0
Lib/hashlib.py
Lib/hashlib.py
+3
-1
Lib/test/test_hashlib.py
Lib/test/test_hashlib.py
+5
-0
No files found.
Doc/library/hashlib.rst
View file @
e6390a15
...
...
@@ -74,6 +74,15 @@ Using :func:`new` with an algorithm provided by OpenSSL:
>>> h.hexdigest()
'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
This module provides the following constant attribute:
.. data:: hashlib.algorithms
A tuple providing the names of the hash algorithms guaranteed to be
supported by this module.
.. versionadded:: 2.7
The following values are provided as constant attributes of the hash objects
returned by the constructors:
...
...
Lib/hashlib.py
View file @
e6390a15
...
...
@@ -58,7 +58,9 @@ More condensed:
# always available algorithm is added.
__always_supported
=
(
'md5'
,
'sha1'
,
'sha224'
,
'sha256'
,
'sha384'
,
'sha512'
)
__all__
=
__always_supported
+
(
'new'
,)
algorithms
=
__always_supported
__all__
=
__always_supported
+
(
'new'
,
'algorithms'
)
def
__get_builtin_constructor
(
name
):
...
...
Lib/test/test_hashlib.py
View file @
e6390a15
...
...
@@ -102,6 +102,11 @@ class HashLibTestCase(unittest.TestCase):
c
=
cons
(
a
)
c
.
hexdigest
()
def
test_algorithms_attribute
(
self
):
self
.
assertEqual
(
hashlib
.
algorithms
,
tuple
([
_algo
for
_algo
in
self
.
supported_hash_names
if
_algo
.
islower
()]))
def
test_unknown_hash
(
self
):
try
:
hashlib
.
new
(
'spam spam spam spam spam'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment