atul.mishra
atul.mishra

Reputation: 35

Encryption not working with key generated from openssl for AES-256

I have generated a key using OpenSSL for AES-256. Below is the line I am executing:

openssl enc -aes-256 -cbc -k Secret_key -P -md sha1 > FILE_NAME.txt

It is generating a key of 64 bytes/characters. When I try encrypting data using this key then I get an error:

java.security.InvalidKeyException: Invalid AES key length: 64 bytes

I am not sure how to use the key generated and also whether the key generated is correctly.

Thanks

Upvotes: 1

Views: 852

Answers (1)

Nickolay Olshevsky
Nickolay Olshevsky

Reputation: 14160

Key for AES-256 should be 32-bytes long. Most likely it is hex-encoded on output.

Upvotes: 2

Related Questions