How to convert hex into a string using Python
There are a few ways depending on the Python version you have on your computer.
Python 2
- >>> "(HexValue)".decode("hex")
- 'string'
- >>> "7368616b6564".decode("hex")
- 'shaked'
Python 2 + 3
- >>> bytearray.fromhex("HexValue").decode()
- 'string'
- >>> bytearray.fromhex("7368616b6564").decode()
- 'shaked'
Python 3
- >>> bytes.fromhex('HexValue').decode('utf-8')
- 'string'
- >>> bytes.fromhex('7368616b6564').decode('utf-8')
- 'shaked'
You can also use Print to convert hex values to text (Add () in print Python 3)
- >>> print "HexValues"
- 'string'
- >>> print "\x73 \x68 \x61 \x6b \x65 \x64"
- 'shaked'
More Information
Convert from ASCII string encoded in Hex to plain ASCII?
Python: hex string to char