The Java KeyGenerator class (
javax.crypto.KeyGenerator) is used to generate symmetric encryption keys. A symmetric encryption key is a key that is used for both encryption and decryption of data, by a symmetric encryption algorithm. In this Java KeyGenerator tutorial I will show you how to generate symmetric encryption keys.
Creating a KeyGenerator Instance
Before you can use the Java
KeyGenerator class you must create a
KeyGenerator instance. You create a
KeyGenerator instance by calling the static method
getInstance() passing as parameter the name of the encryption algorithm to create a key for. Here is an example of creating a Java
This example creates a
KeyGenerator instance which can generate keys for the AES encryption algorithm.
Initializing the KeyGenerator
Encryption Key Generator 128 Bit
Mar 12, 2020 Use the OpenSSL command-line tool, which is included with InfoSphere MDM, to generate AES 128-, 192-, or 256-bit keys. The madpwd3 utility is used to create the password. Feb 01, 2001 The 128-bit version of WLS contains a Certificate servlet that is able to generate keys and Certificate Signing Requests for 128/1024-bit SSL certificates. + Mikael 'Wolfgang Mehl' wrote: BEA at least in Germany is not able to devliver a certificate Servlet to generate 1024 bit keys, so use.
After creating the
KeyGenerator instance you must initialize it. Initializing a
KeyGenerator instance is done by calling its
init() method. Here is an example of initializing a
init() method takes two parameters: The bit size of the keys to generate, and a
SecureRandom that is used during key generation.
Generating a Key
Once the Java
KeyGenerator instance is initialized you can use it to generate keys. Generating a key is done by calling the
generateKey() method. Here is an example of generating a symmetric key: