Java add aes key to keystore
Java add aes key to keystore
If you’re doing symmetric encryption in Java and want to store your AES keys securely rather than in a config file, the Java KeyStore is the right place. Note the store type matters: jceks supports secret keys, regular jks doesn’t. This trips people up constantly.
- For store type jceks with keysize 256
1
$ keytool -genseckey -keystore keystore.jck -storetype jceks -storepass changeitplease -keyalg AES -keysize 256 -alias app1_aes_encryption_key -keypass changeitplease
- For store type p12 with keysize 512
1
$ keytool -genseckey -keystore keyStore.p12 -storetype pkcs12 -storepass 'changeitplease' -keyalg aes -keysize 512 -alias app1_aes_encryption_key -keypass 'changeitplease'
This post is licensed under
CC BY 4.0
by the author.