wood burning stoves*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Security
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How use the same SecretKey (not random each time it runs) ?
 
Similar Threads
BadPaddingException in AES
3DES encryption and decryption
Triple Des Pin Encryption
String encryption/decryption - 'block not properly padded' error
Cache the contents of KeyStore and convert it to a InputStream