16进制转字符串:
方法一:
(使用前提:安装了Crypto库,否则一般不用此种方法)
'''16进制转字符串'''
from Crypto.Util.number import *
c = 0x666c61677b32303665383539643865383534633466363030636231323735376262663966357d
print(long_to_bytes(c).decode())
# 结果:flag{206e859d8e854c4f600cb12757bbf9f5}
'''字符串转16进制'''
m = 'flag{206e859d8e854c4f600cb12757bbf9f5}' # 字符串状态
m = bytes_to_long(m.encode())) # 10进制状态
print(hex(m)) # 16进制状态
# 结果:666c61677b32303665383539643865383534633466363030636231323735376262663966357d
方法二:
'''16进制转字符串'''
c = '666c61677b32303665383539643865383534633466363030636231323735376262663966357d'
print(bytes.fromhex(c).decode())
# 结果:flag{206e859d8e854c4f600cb12757bbf9f5}
'''字符串转16进制'''
m = 'flag{206e859d8e854c4f600cb12757bbf9f5}'
print(m.encode().hex())
# 结果:666c61677b32303665383539643865383534633466363030636231323735376262663966357d
方法三:
'''16进制转字符串'''
import binascii
c = '666c61677b32303665383539643865383534633466363030636231323735376262663966357d'
print(binascii.unhexlify(c).decode())
# 结果:flag{206e859d8e854c4f600cb12757bbf9f5}
'''字符串转16进制'''
m = 'flag{206e859d8e854c4f600cb12757bbf9f5}'
print(binascii.hexlify(c).decode())
# 结果:666c61677b32303665383539643865383534633466363030636231323735376262663966357d