New submission from Pavel Trukhanov <pavel.trukha...@gmail.com>:
The documentation found in https://docs.python.org/3/library/hashlib.html#hash-algorithms give us the following two examples: ``` For example, to obtain the digest of the byte string b'Nobody inspects the spammish repetition': >>> >>> import hashlib >>> m = hashlib.sha256() >>> m.update(b"Nobody inspects") >>> m.update(b" the spammish repetition") >>> m.digest() b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06' >>> m.digest_size 32 >>> m.block_size 64 More condensed: >>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest() 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2' hashlib ``` It's confusing because two examples use different algo - sha256 and sha224, respectfully. Also the first one gets `.digest()` while the other - `.hexdigest()`, which are incomparable. ---------- assignee: docs@python components: Documentation messages: 373619 nosy: Pavel Trukhanov, docs@python priority: normal severity: normal status: open title: fix confusing example in hashlib docs _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41293> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com