[英]How can I specify an AES key in Python?
I'm working on converting a Java program into Python and part of its core networking uses AES encryption to handle packets going up and down the line. 我正在将Java程序转换为Python,并且其部分核心网络使用AES加密来处理上下传输的数据包。 Java's AES is initialized like so: Java的AES初始化如下:
byte[] key = { 0x13, 0x00, 0x00, 0x00 };
sKeySpec = new SecretKeySpec(key, "AES");
I want to do the same in Python, and will use PyCrypto, but I'm not sure how to initialize the above in it as it only allows string-based "secret keys." 我想在Python中做同样的事情,并且将使用PyCrypto,但是我不确定如何在其中初始化以上内容,因为它仅允许基于字符串的“秘密密钥”。
然后使用一个字符串
key = '\x13\x00\x00\x00'
为什么不尝试使用Jython,因为您可以直接导入.class文件而无需重新编写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.