I’m using PyCrypto, and python 2.7.3. I’m attempting to prepend a regular string to the hash to create a chained hash, but to keep formats consistent, I need the string s in the ‘printed’ form instead of the binary form. Is there any way to convert the binary string into a manipulable “normal” string?
from Crypto.Hash import SHA256
h = SHA256.new()
s = h.digest() #return binary "non-printable" digest
s
>>>"\xe3\xb0\xc4B\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99o\xb9$'\xaeA\xe4d\x9b\x93L\xa4\x95\x99\x1bxR\xb8U"
print(s)
>>> ã°ÄB˜üšûôÈ™o¹$'®Aäd›“L¤•™xR¸U
Thanks for any help
What you see when entering
sin the interactive interpreter is the representation of the string. You shouldn’t be concerned about what this looks like – the actual string contents is what gets printed when you use print. There is no way to “convert” the string to what is printed when usingprintsince the string already has that contents.