开发者

Want to create a key for the AES encryption

开发者 https://www.devze.com 2023-04-12 09:04 出处:网络
I want to create a key for use in AES encryption.I found a way to do this using Java\'s keytool.The trick was to specify that the type of the keystore was JCEKS, not the default JCE.

I want to create a key for use in AES encryption. I found a way to do this using Java's keytool. The trick was to specify that the type of the keystore was JCEKS, not the default JCE.

So this command will create the key:

开发者_如何学编程
keytool -genseckey -alias aestest  -keyalg AES -keysize 192  -storetype JCEKS

My questions are:

  1. how in the heck do I get that generated key out of the keystore, and into a file so I can use it!?

  2. are there any special properties that an AES key must have, or can I choose any arbitrary 192 bits as my AES key, thus avoiding needing to use keytool at all?

Thanks Peter


You can choose an arbitrary key - any random data will do. Generally the only scenario in which you're likely to need an actual key generator is when you're generating a pair of keys (public and private), in which case those two keys have to be mathematically linked, but AES is a symmetric cipher and only has the one key, which can be anything.


U need not get the generated key out of a keystore. U can use it by giving keystore password. Here is a UI to generate the key in a keytool. http://www.fuin.org/keytool-iui/keytool-iui.jnlp. Run following commands a. jarsigner -verbose -keystore keys.jks Unsigned.apk alias b. zipalign -f -v 4 Signed.apk Zipped.apk

Refer this: http://developer.android.com/guide/publishing/app-signing.html

I dont think using any 192 bits as AES key, thus avoiding needing to use keytool at all will work. Even it does, its not a berst practice as u need the same key while updating ur app.

0

精彩评论

暂无评论...
验证码 换一张
取 消