How do I Generate AES key with seed value so that whenever I generate key with same seed value,I shud be able to get the same AES key?
I want to generate this key for my Blackberry Pearl 8100 device.
I am not able to generate AES key with AESKey(keyData) .
Also whenever I print it either in the form of String or byte[] , I am not able to generate it.(print it) Actual key is never printed.
What can be done to get the key?
Update
I tried generating AESKey by passing byte[] of my data,as follws:
AESKey key = new AESKey(keyData);
Everytime I get same key, which is correct.
Now using this key I am encrypting the data.Everytime I encrypt I get different value of encryption. Here is my problem. How can I get same data everytime after encryption,so that I can send it to server?
Update
I am not able to generate AES key with AESKey(keyData) .
Also whenever I print it either in the form of String or byte[] , I am not able to generate it.(print it) Actual key is never printed.
What can be done to get the key?
Section 5.2 in RFC 2898 describes one way of doing this.
Specifically, the "seed" value consists of a "PASSPHRASE" and a "SALT"; but given the same passphrase and salt, will always result in the same key.
http://anandam.name/pbkdf2/ is a javascript implementation.
http://en.wikipedia.org/wiki/PBKDF2 has more information, and links to other implementations.
This can not be done in a secure manner. You should not be generating encryption keys like this, particularly if you intend to protect anything important with the resulting keys. Nonetheless, a basic algorithm to do it looks like this (many enhancements are possible, but none will make it really secure):
N
bytes of RNG output; those are your encryption key. As long as you seed with the same value in step 2, the first N
bytes generated will always be the same.None
, for instance; that tells the machine to choose any random seed).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With