mirror of
https://github.com/python/cpython.git
synced 2025-12-03 08:04:34 +00:00
gh-136565: use SHA-256 for hashlib.__doc__ example instead of MD5 (#138157)
This commit is contained in:
parent
ce1a877a38
commit
1700cc4d76
1 changed files with 8 additions and 8 deletions
|
|
@ -36,21 +36,21 @@ Hash objects have these methods:
|
||||||
efficiently compute the digests of data that share a common
|
efficiently compute the digests of data that share a common
|
||||||
initial substring.
|
initial substring.
|
||||||
|
|
||||||
Assuming that Python has been built with MD5 support, the following computes
|
Assuming that Python has been built with SHA-2 support, the SHA-256 digest
|
||||||
the MD5 digest of the byte string b'Nobody inspects the spammish repetition':
|
of the byte string b'Nobody inspects the spammish repetition' is computed
|
||||||
|
as follows:
|
||||||
|
|
||||||
>>> import hashlib
|
>>> import hashlib
|
||||||
>>> m = hashlib.md5()
|
>>> m = hashlib.sha256()
|
||||||
>>> m.update(b"Nobody inspects")
|
>>> m.update(b"Nobody inspects")
|
||||||
>>> m.update(b" the spammish repetition")
|
>>> m.update(b" the spammish repetition")
|
||||||
>>> m.digest()
|
>>> m.digest() # doctest: +ELLIPSIS
|
||||||
b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
|
b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7...'
|
||||||
|
|
||||||
More condensed:
|
More condensed:
|
||||||
|
|
||||||
>>> hashlib.md5(b"Nobody inspects the spammish repetition").hexdigest()
|
>>> hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest()
|
||||||
'bb649c83dd1ea5c9d9dec9a18df0ffe9'
|
'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This tuple and __get_builtin_constructor() must be modified if a new
|
# This tuple and __get_builtin_constructor() must be modified if a new
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue