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

KeygenerateKeyAES()
generate Key AES
return new SecretKeySpec(KEY_VALUE_128_BIT, AES_ALGO);
byte[]generateKeyDigest(int keyLength, String password)
generate Key Digest
try {
    MessageDigest digester = MessageDigest.getInstance("MD5");
    int length = (keyLength + 15) / 16 * 16;
    byte[] passwordBytes = password.getBytes("UTF-8");
    byte[] temp = digester.digest(passwordBytes);
    byte[] key = Arrays.copyOf(temp, length);
    for (int i = 1; i < length / 16; i++) {
        temp = Arrays.copyOf(temp, 16 + passwordBytes.length);
...
KeygenerateKeyFromString(final String secKey, String algorithm)
generate Key From String
final byte[] keyVal = Base64.getDecoder().decode(secKey.getBytes());
final Key key = new SecretKeySpec(keyVal, algorithm);
return key;
KeyPairgenerateKeyPair()
generate Key Pair
return generateKeyPair(1024);
KeyPairgenerateKeyPair()
generate Key Pair
try {
    final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
    keyPairGenerator.initialize(KEY_SIZE);
    return keyPairGenerator.generateKeyPair();
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
KeyPairgenerateKeyPair()
Generate key which contains a pair of private and public key using 1024 bytes
KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM);
keyGen.initialize(keyLength);
KeyPair keyPair = keyGen.generateKeyPair();
return keyPair;
KeyPairgenerateKeyPair()
generate Key Pair
return generateKeyPair("RSA");
KeyPairgenerateKeyPair()
generate Key Pair
if (generator == null) {
    generator = KeyPairGenerator.getInstance("RSA");
generator.initialize(2048);
return generator.genKeyPair();
KeyPairgenerateKeyPair()
generate Key Pair
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(getKeySize());
KeyPair keyPair = keyPairGenerator.generateKeyPair();
return keyPair;
KeyPairgenerateKeyPair()
generate Key Pair
KeyPairGenerator gen = KeyPairGenerator.getInstance(encryptionAlgorithm);
gen.initialize(keysize);
return gen.generateKeyPair();