这段易语言代码转Py,问题出在哪?有的数据转换结果一样,有的不行
|
xor_encrypt | 字节集 | | |
message | 字节集 | | | | box | 字节集 | | | |
变量名 | 类 型 | 静态 | 数组 | 备 注 | encrypt_list | 字节集 | | | i | 整数型 | | | boxtemp | 字节集 | | | temp | 字节型 | | |
boxtemp = box 调试输出 (“xor_encrypt开始 - 输入数据长度:”, 取字节集长度 (message )) 调试输出 (“box长度:”, 取字节集长度 (box )) 计次循环首 (取字节集长度 (message ), i ) boxtemp [1 ] = boxtemp [1 ] + boxtemp [i + 1 ] 如果真 (boxtemp [1 ] > 255 )  boxtemp [1 ] = 位异或 (boxtemp [1 ], 256 ) temp = boxtemp [i + 1] boxtemp [i + 1 ] = boxtemp [boxtemp [1 ] + 1 ] boxtemp [boxtemp [1 ] + 1 ] = temp  encrypt_list = encrypt_list + 到字节集 (到字节 (位异或 (message [i ], boxtemp [1 + 位与 (boxtemp [i + 1 ] + boxtemp [1 + boxtemp [1 ]], 255 )])) ) 计次循环尾 ()返回 (encrypt_list )
def xor_encrypt(self, message, box):
boxtemp = bytearray(box)
encrypt_list = bytearray()
for i in range(len(message)):
boxtemp[0] = (boxtemp[0] + boxtemp[i + 1]) & 0xFF
temp = boxtemp[i + 1]
boxtemp[i + 1] = boxtemp[boxtemp[0]]
boxtemp[boxtemp[0]] = temp
index = (boxtemp[i + 1] + boxtemp[boxtemp[0]]) & 0xFF
encrypted_byte = message[i] ^ boxtemp[index]
encrypt_list.append(encrypted_byte)
return bytes(encrypt_list)
a_bogus.e
(792.72 KB, 下载次数: 3)
|