This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author beazley
Recipients beazley, georg.brandl
Date 2008-12-29.19:54:12
SpamBayes Score 0.003966701
Marked as misclassified No
Message-id <1230580453.49.0.84124540876.issue4771@psf.upfronthosting.co.za>
In-reply-to
Content
The hashlib documentation has incorrect examples showing the use of the 
hexdigest() method:

>>> hashlib.sha224(b"Nobody inspects the spammish 
repetition").hexdigest()
b'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
>>>

and this one

>>> h = hashlib.new('ripemd160')
>>> h.update(b"Nobody inspects the spammish repetition")
>>> h.hexdigest()
b'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
>>>

However, the result of h.hexdigest() is of type 'str', not bytes. Actual 
output:

>>> h.hexdigest()
'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
>>> 

Sure would be nice if that string of hex digits was easy to decode back 
into a binary string.  

>>> import binascii
>>> b = binascii.a2b_hex(h.hexdigest())
>>>

Hmmm. So *SOME* of the functions in binascii do accept Unicode strings. 
See Issue 4470 :-).
History
Date User Action Args
2008-12-29 19:54:14beazleysetrecipients: + beazley, georg.brandl
2008-12-29 19:54:13beazleysetmessageid: <1230580453.49.0.84124540876.issue4771@psf.upfronthosting.co.za>
2008-12-29 19:54:12beazleylinkissue4771 messages
2008-12-29 19:54:12beazleycreate