1

Hi i have the following code in python3.4.2:

s='416f1c7918f83a4f1922d86df5e78348'; w="0123456789abcdef"; x=''.join([chr(w.index(s[i])*16+w.index(s[i+1])) if(i%2==0) else '' for i in range(len(s))]); print(x);

and it shows this error
UnicodeEncodeError: 'ascii' codec can't encode character '\xf8' in position 5: ordinal not in range (128)

Why is this happening ? isn't chr in python3 supposed to take more than 128 ?

1 Answers1

0

Too much work.

>>> binascii.unhexlify(s)
b'Ao\x1cy\x18\xf8:O\x19"\xd8m\xf5\xe7\x83H'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358