1

anyone know how do i decode my Hex value on Python version 3.6.0 ?

i was using x.decode("hex") but since python update it doesn't work anymore.

here is my hex value:

01008C647620302E31302E372070762039393130333120736E20333137337C6661336232653863206D7A20313778313720736B6620343235357C34376330643162302073706620333237397C363236373361376520627066203332363137307C61653138366364642073746620323538397C623634383035633220616D66203335333230357C633736333133626200

1 Answers1

2

In Python 3.6 there is no need to decode strings (of type str), since they are already utf-8. Further, the normal decode function, allows only "standard" string decodings. That is, this function cannot decode hex.

Instead, this "special" decoding functionality is moved to codecs.decode. Thus, you want to rewrite your code as:

import codecs
x = "01008C647620302E31302E372070762039393130333120736E20333137337C6661336232653863206D7A20313778313720736B6620343235357C34376330643162302073706620333237397C363236373361376520627066203332363137307C61653138366364642073746620323538397C623634383035633220616D66203335333230357C633736333133626200"
codecs.decode(x, 'hex')
JohanL
  • 6,671
  • 1
  • 12
  • 26