This class generates a public/private key pair
for a specified cryptographic algorithm. To create a
KeyPairGenerator, call one of the static
getInstance( )
methods, specifying the name of the algorithm and, optionally, the
name or Provider object of the security provider
to use. The default "SUN" provider
shipped with Java 1.2 supports only the
"DSA" algorithm. The
"SunJCE" provider of the Java
Cryptography Extension (JCE) additionally supports the
"DiffieHellman" algorithm.
Once you have created a
KeyPairGenerator, initialize it by calling
initialize( ). You can perform an
algorithm-independent initialization by simply specifying the desired
key size in bits. Alternatively, you can do an algorithm-dependent
initialization by providing an appropriate
AlgorithmParameterSpec object for the
key-generation algorithm. In either case, you may optionally provide
your own source of randomness in the guise of a
SecureRandom object. Once you have created and
initialized a KeyPairGenerator, call
genKeyPair(
) to create a KeyPair object. Remember
that the KeyPair contains a
PrivateKey that must be kept
private.
For historical reasons, KeyPairGenerator extends
KeyPairGeneratorSpi. Applications should not use
any methods inherited from that class.

public abstract class KeyPairGenerator extends KeyPairGeneratorSpi {
// Protected Constructors
protected KeyPairGenerator(String algorithm);
// Public Class Methods
public static KeyPairGenerator getInstance(String algorithm)
throws NoSuchAlgorithmException;
1.4 public static KeyPairGenerator getInstance(String algorithm,
Provider provider) throws NoSuchAlgorithmException;
public static KeyPairGenerator getInstance(String algorithm,
String provider)
throws NoSuchAlgorithmException, NoSuchProviderException;
// Public Instance Methods
1.2 public final KeyPair genKeyPair( );
public String getAlgorithm( );
1.2 public final Provider getProvider( );
1.2 public void initialize(java.security.spec.AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException;
public void initialize(int keysize);
// Public Methods Overriding KeyPairGeneratorSpi
public KeyPair generateKeyPair( ); constant
1.2 public void initialize(java.security.spec.AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidAlgorithmParameterException; empty
public void initialize(int keysize, SecureRandom random); empty
}