pythonbyte十六进制_在python中循环使用8byte十六进制代码

我有一个8字节的十六进制代码,我试图从最后一个字节循环到第一个字节的00-FF,但我对python还不熟悉,我被卡住了。在

以下是循环00-FF的代码:for h in range(0, 256):

return "{:02x}".format(h)

基本上我所拥有的是

^{pr2}$

编辑:我将添加一些关于这个的背景信息,并删除我之前的解释。我在写一个用DES的填充攻击算法。需要做的是:hexcode = 'f20bdba6ff29eed7'

for i in range(0,8):

(FOR i = 0 ) Loop through 00-FF for the last byte (i.e. 'd7') until you find the value that works

(FOR i = 1 ) Loop through 00-FF for the 7th byte (i.e. 'ee') until you find the value that works

and so on until the 1st byte

我的问题:我的问题是我不知道如何循环通过所有8字节的十六进制。当它是第8个字节时,这很简单,因为我只删除最后两个元素,循环00-FF并将其添加回hex,看看它是否是正确的代码。基本上,代码的作用是:remove last two elements of hex

try 00 as the last two elements

if the test returns true then stop

if it doesn't move to 01 (cont. through FF, but stop when you find the correct value)

我的问题是,当字节在中间(2-7)时,我如何循环获取一个中间值,然后将其全部相加。本质上For byte 7:

Remove elements 13,14 from hex

try 00 as element 13,14

add hex[0:12] + 00 + hex [15:16]

if 00 returns true then stop, if not then loop through 01-ff until it does

对于字节6、5、4、3、2、1,以此类推

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值