From 2fcf847f01a78e6490925793d78fe770206ad77a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 26 Aug 2025 12:13:06 +0200 Subject: [PATCH] use SHA-256 for hashlib example instead of MD-5 --- Lib/hashlib.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/hashlib.py b/Lib/hashlib.py index 8e7083ba692348..6c73eb9f31f8e4 100644 --- a/Lib/hashlib.py +++ b/Lib/hashlib.py @@ -36,21 +36,21 @@ efficiently compute the digests of data that share a common initial substring. -Assuming that Python has been built with MD5 support, the following computes -the MD5 digest of the byte string b'Nobody inspects the spammish repetition': +Assuming that Python has been built with SHA-2 support, the SHA-256 digest +of the byte string b'Nobody inspects the spammish repetition' is computed +as follows: >>> import hashlib - >>> m = hashlib.md5() + >>> m = hashlib.sha256() >>> m.update(b"Nobody inspects") >>> m.update(b" the spammish repetition") - >>> m.digest() - b'\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' + >>> m.digest() # doctest: +ELLIPSIS + b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7...' More condensed: - >>> hashlib.md5(b"Nobody inspects the spammish repetition").hexdigest() - 'bb649c83dd1ea5c9d9dec9a18df0ffe9' - + >>> hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest() + '031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406' """ # This tuple and __get_builtin_constructor() must be modified if a new