This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Security and the fly likes How use the same SecretKey (not random each time it runs) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Security
Reply Bookmark "How use the same SecretKey (not random each time it runs) ?" Watch "How use the same SecretKey (not random each time it runs) ?" New topic
Author

How use the same SecretKey (not random each time it runs) ?

Daniel Rodriguez Hernandez
Greenhorn

Joined: Nov 26, 2009
Posts: 13
Hi everybody.

I need to encrypt and decrypt using the same SecretKey for AES, but if you use the method "GenerateKey ()", it generates a new key every time ..

Is there a way to encrypt and decrypt with a key defined by me, not creating a new one every time?

Thank you.
greg stark
Ranch Hand

Joined: Aug 10, 2006
Posts: 220
use a SecretKeySpec.


Nice to meet you.
Daniel Rodriguez Hernandez
Greenhorn

Joined: Nov 26, 2009
Posts: 13
Ok, thank you..

I used SecretKeySpec but it threw me a "Invalid length key 7 bytes"... Then I read that the key must be of length 16 bytes... i.e, a character per byte, 16 character..

Now It works fine.

Thank you
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How use the same SecretKey (not random each time it runs) ?
 
Similar Threads
BadPaddingException in AES
Triple Des Pin Encryption
Cache the contents of KeyStore and convert it to a InputStream
3DES encryption and decryption
String encryption/decryption - 'block not properly padded' error