Java Key Create getKeyPair()

Here you can find the source of getKeyPair()

Description

get Key Pair

License

Apache License

Declaration

public static KeyPair getKeyPair() throws Exception 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.security.KeyPair;
import java.security.KeyPairGenerator;

public class Main {
    private static final String KEY_ALGORITHM = "RSA";
    private static final int KEY_SIZE = 512;

    public static KeyPair getKeyPair() throws Exception {
        KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM);
        kpGenerator.initialize(KEY_SIZE);
        KeyPair keyPair = kpGenerator.generateKeyPair();
        return keyPair;
    }//w w w  . ja v  a 2 s  .  c  o m
}

Related

  1. getKeyManagerFactory(KeyStore store, char[] password)
  2. getKeyManagerFactory(Map stores)
  3. getKeyManagers()
  4. getKeyManagers(KeyStore keyStore, String keyPassword)
  5. getKeyManagers(KeyStore ks, String password)
  6. getKeyPair()
  7. getKeyPair()
  8. getKeyPair(KeyStore keyStore, String alias, String password)
  9. getKeyPairGenerator(final String algorithm)