Reputation: 35
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
Reputation: 14160
Key for AES-256 should be 32-bytes long. Most likely it is hex-encoded on output.
Upvotes: 2