A previous question was asked and the reader was ask to use hexdigest() instead. ...and that does work. But what is the structure of the format of digest?
The following test code:
import hashlib, base64
f1 = open('foo.jpeg', 'rb')
m = hashlib.sha512()
m.update(f1.read())
sha = m.digest()
print(m.digest())
print(m.hexdigest())
res = base64.b64encode(sha)
print( res)
produces the following output:
>>>
b'\xf3g\xd1S\xc4#OK\xb8\xb7\x1f~r\xf0\x19JE\xb0d\xb9\x11O\x08\x1c\xc66\x00\xb3i*\x87\x08\x92+\xd3)F\x02\t\x80\xf0m\x8b;\x9c\xcdq\xbd\xb9\x92k\x7f}d\t\xc65\x12\x0b\x17\xf9]5\x97'
f367d153c4234f4bb8b71f7e72f0194a45b064b9114f081cc63600b3692a8708922bd32946020980f06d8b3b9ccd71bdb9926b7f7d6409c635120b17f95d3597
>>>
I don't get what the parts like "#OK", "~r", "i*" etc. mean in the first line of output above. Any light that can be shed on this would be greatly appreciated. The hexdigest() output, of course, makes perfect sense.
Previous question was: hashlib.sha256 returned some weird characters in python. Many Thanks.