Python:列表转十六进制
我正在编写一个小型取证 python 应用程序,但在将列表条目转换为十六进制时遇到问题。我尝试过编码/解码方法,但出现虚假转换或奇数长度字符串类型错误。我粘贴了下面的代码,正如您所看到的,我需要十六进制的地址,这样我就可以向其中添加计数。
def location_finder(line):
count = 0
temp = line.split(' ') #3 Tokenizes first element, by first space
address = str(temp[0].split(':')) # Take's : off of first element(address)
print address, "dog"
address = address.decode("hex")
print address, "cat"
#print temp[0]
line_address = temp[0].upper()
for addy in temp:
if addy == "ffd8":
return (address+count)
if addy == "ffd9":
return (address+count)
count = count + 1
I am writing a small forensics python app and I am having trouble converting a List entry to Hex. I have tried the encode/decode methood but get bogus conversions or odd-length string Type Errors. I have pasted the code below, and as you can see I need the address in hex, so I can add the count to it.
def location_finder(line):
count = 0
temp = line.split(' ') #3 Tokenizes first element, by first space
address = str(temp[0].split(':')) # Take's : off of first element(address)
print address, "dog"
address = address.decode("hex")
print address, "cat"
#print temp[0]
line_address = temp[0].upper()
for addy in temp:
if addy == "ffd8":
return (address+count)
if addy == "ffd9":
return (address+count)
count = count + 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
hex
函数将整数转换为其十六进制表示形式:The
hex
function converts integers to their hexadecimal representation: