Skip to content

Commit 1700cc4

Browse files
authored
pythongh-136565: use SHA-256 for hashlib.__doc__ example instead of MD5 (python#138157)
1 parent ce1a877 commit 1700cc4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Lib/hashlib.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@
3636
efficiently compute the digests of data that share a common
3737
initial substring.
3838
39-
Assuming that Python has been built with MD5 support, the following computes
40-
the MD5 digest of the byte string b'Nobody inspects the spammish repetition':
39+
Assuming that Python has been built with SHA-2 support, the SHA-256 digest
40+
of the byte string b'Nobody inspects the spammish repetition' is computed
41+
as follows:
4142
4243
>>> import hashlib
43-
>>> m = hashlib.md5()
44+
>>> m = hashlib.sha256()
4445
>>> m.update(b"Nobody inspects")
4546
>>> m.update(b" the spammish repetition")
46-
>>> m.digest()
47-
b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9'
47+
>>> m.digest() # doctest: +ELLIPSIS
48+
b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7...'
4849
4950
More condensed:
5051
51-
>>> hashlib.md5(b"Nobody inspects the spammish repetition").hexdigest()
52-
'bb649c83dd1ea5c9d9dec9a18df0ffe9'
53-
52+
>>> hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest()
53+
'031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'
5454
"""
5555

5656
# This tuple and __get_builtin_constructor() must be modified if a new

0 commit comments

Comments
 (0)