str to hex:

import codecs
hexlify = codecs.getencoder('hex')
hexlify(b'Blaah')[0]

out:

b'426c616168'

hex to str:

import codecs
decode_hex = codecs.getdecoder("hex_codec")
s = decode_hex(b'426c616168')[0]

out:

b'Blaah'

标签:无

你的评论