I think you need it the other way around. "Dummy String"
is not a valid number in hex
. You can hexlify
it:
>>> binascii.hexlify('Dummy String')
'44756d6d7920537472696e67'
but not unhexlify
it. unhexlify
takes a string in hex
and turns it into it's ASCII representation:
>>> binascii.unhexlify('44756d6d7920537472696e67')
'Dummy String'
What you need is to md5
the string ("Dummy String"
in our case) and unhexlify
it's hash:
import binascii
import hashlib
the_hash = hashlib.md5('Dummy String').hexdigest()
print the_hash
the_unhex = binascii.unhexlify(the_hash)
print the_unhex
Which yields the hash, and the unhexlified hash:
ec041da9f891c09b3d1617ba5057b3f5
ЛLЬ-ю?=¦PWЁУ
Note: although the output doesn't look exactly like yours - "??????=?PW??", the "PW" and "=" in both, makes me pretty certain it's correct.