Java Key Pair Create generateKeyPair()

Here you can find the source of generateKeyPair()

Description

Generate a random key pair.

License

Apache License

Return

KeyPair containg private and public key

Declaration

public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException 

Method Source Code


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

import java.security.*;

public class Main {
    /**/*from  w  w w .j a  v a  2 s .  c om*/
     * Generate a random key pair.
     * @return KeyPair containg private and public key
     */
    public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException {
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
        keyGen.initialize(1024, random);
        return keyGen.generateKeyPair();
    }
}

Related

  1. generateKeyPair()
  2. generateKeyPair()
  3. generateKeyPair()
  4. generateKeyPair()
  5. generateKeyPair()
  6. generateKeyPair()
  7. generateKeyPair()
  8. generateKeyPair()
  9. generateKeyPair()