Java Utililty Methods Key Pair Create

List of utility methods to do Key Pair Create

Description

The list of methods to do Key Pair Create are organized into topic(s).

Method

KeyPairgenerateKeyPair()
generate Key Pair
KeyPairGenerator generator = null;
SecureRandom secureRandom = null;
try {
    generator = KeyPairGenerator.getInstance(CIPHER_ALGORITHM);
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("Could not generate key", e);
try {
...
KeyPairgenerateKeyPair(final Provider provider, final String keyPairAlgorithm, final String secureAlgorithm)
generate Key Pair
try {
    KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(keyPairAlgorithm, provider);
    SecureRandom secureRandom = SecureRandom.getInstance(secureAlgorithm);
    keyPairGenerator.initialize(1024, secureRandom);
    synchronized (lockObject) {
        LAST_GENERATED_KEY_PAIR = keyPairGenerator.generateKeyPair();
        return LAST_GENERATED_KEY_PAIR;
} catch (Exception e) {
    throw new RuntimeException(e);
KeyPairgenerateKeyPair(final String algorithm, final int keylen)
generate Key Pair
KeyPairGenerator kpGen = KeyPairGenerator.getInstance(algorithm);
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
kpGen.initialize(keylen, random);
return kpGen.generateKeyPair();
KeyPairgenerateKeyPair(final String algorithmModePad, final int keySize)
Generate KeyPair
KeyPair keyPair = null;
try {
    final KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithmModePad);
    keyGen.initialize(keySize);
    keyPair = keyGen.generateKeyPair();
} catch (Exception e) {
    e.printStackTrace();
return keyPair;
KeyPairgenerateKeyPair(int bit)
generate Key Pair
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORTHM);
keyPairGenerator.initialize(bit);
KeyPair keyPair = keyPairGenerator.generateKeyPair();
return keyPair;
KeyPairgenerateKeyPair(int keySize)
generate Key Pair
KeyPairGenerator generator = KeyPairGenerator.getInstance(KEYGEN_ALGORITHM);
SecureRandom secureRandom = SecureRandom.getInstance(SECURE_RANDOM_ALGORITHM);
generator.initialize(keySize, secureRandom);
return generator.generateKeyPair();
KeyPairgenerateKeyPair(int keySize)
generate Key Pair
KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", providerName);
generator.initialize(keySize);
return generator.generateKeyPair();
KeyPairgenerateKeyPair(int keySize)
Generate a new RSA keypair.
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(keySize);
return keyPairGenerator.genKeyPair();
KeyPairgenerateKeyPair(int keySize)
Generates a new key pair.
KeyPairGenerator generator = KeyPairGenerator.getInstance(ALGORITHM_SIGNATURE);
generator.initialize(keySize);
return generator.generateKeyPair();
KeyPairgenerateKeyPair(int keysize)
Generates a RSA key pair with the provided key size (in bits)
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(keysize);
return keyPairGenerator.generateKeyPair();