简体   繁体   English

Python中的单字节乘法?

[英]Single Byte Multiplication in Python?

I have a requirement to decode a file using simple byte multiplication 我需要使用简单的字节乘法来解码文件

For every byte in the file, the byte value is muliplied by 0x69. 对于文件中的每个字节,字节值乘以0x69。 The result cannot be a word, it must be a single byte. 结果不能是一个字,必须是一个字节。

example: 例:

0x24 * 0x69 = 0xc4
0x6c * 0x69 = 0x4c
etc.

Sorry for not posting code, but have no idea on an existing approach. 很抱歉没有发布代码,但对现有方法一无所知。 Thanks 谢谢

What about 关于什么

(0x6c * 0x69) & 0xFF

?

And if you want the hex representation in a string, you can do: 而且,如果您想在字符串中使用十六进制表示,则可以执行以下操作:

hex(result)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM