[issue41293] fix confusing example in hashlib docs

2020-07-13 Thread Pavel Trukhanov


Change by Pavel Trukhanov :


--
type:  -> enhancement
versions: +Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 
<https://bugs.python.org/issue41293>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41293] fix confusing example in hashlib docs

2020-07-13 Thread Pavel Trukhanov


New submission from Pavel Trukhanov :

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 
<https://bugs.python.org/issue41293>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com