d0ctor
d0ctor

Reputation: 925

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's AES is initialized like so:

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."

Upvotes: 0

Views: 708

Answers (2)

JBernardo
JBernardo

Reputation: 33407

Use a string then

key = '\x13\x00\x00\x00'

Upvotes: 2

Gautam
Gautam

Reputation: 7958

Why Don't you Try using Jython , because You can directly import the .class file without having to re-write it .

Upvotes: 1

Related Questions