All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class javax.crypto.KeyGenerator

java.lang.Object
    |
    +----javax.crypto.KeyGenerator

public class KeyGenerator
extends Object
This class provides the functionality of a (symmetric) key generator.

Key generators are constructed using the getInstance class method of this class.

KeyGenerator objects are reusable, i.e., after a key has been generated, the same KeyGenerator object can be re-used to generate further keys.

See Also:
SecretKey, java.security.AlgorithmParameters, java.security.spec.AlgorithmParameterSpec

Constructor Index

 o KeyGenerator(KeyGeneratorSpi, Provider, String)
Creates a KeyGenerator object.

Method Index

 o generateKey()
Generates a secret key.
 o getAlgorithm()
Returns the standard name of the key algorithm.
 o getInstance(String)
Generates a KeyGenerator object for the specified key algorithm.
 o getInstance(String, String)
Generates a KeyGenerator object for the specified key algorithm from the specified provider.
 o getProvider()
Returns the provider of this KeyGenerator object.
 o init(AlgorithmParameterSpec)
Initializes the key generator with the specified parameter set, using a system-provided source of randomness.
 o init(AlgorithmParameterSpec, SecureRandom)
Initializes the key generator with the specified parameter set and a user-provided source of randomness.
 o init(SecureRandom)
Initializes the key generator.

Constructors

 o KeyGenerator
protected KeyGenerator(KeyGeneratorSpi keyGenSpi,
                       Provider provider,
                       String algorithm)
Creates a KeyGenerator object.

Parameters:
keyGenSpi - the delegate
provider - the provider
algorithm - the algorithm

Methods

 o getAlgorithm
public final String getAlgorithm()
Returns the standard name of the key algorithm. See Appendix A in the Java Cryptography Extension API Specification & Reference for information about standard algorithm names.

Returns:
the standard algorithm name.
 o getInstance
public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
Generates a KeyGenerator object for the specified key algorithm.

Parameters:
algorithm - the standard name of the requested key algorithm. See Appendix A in the Java Cryptography Extension API Specification & Reference for information about standard algorithm names.
Returns:
the new KeyGenerator object
Throws: NoSuchAlgorithmException
if a key generator for the requested algorithm is not available
 o getInstance
public static final KeyGenerator getInstance(String algorithm,
                                             String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Generates a KeyGenerator object for the specified key algorithm from the specified provider.

Parameters:
algorithm - the standard name of the requested key algorithm. See Appendix A in the Java Cryptography Extension API Specification & Reference for information about standard algorithm names.
provider - the name of the provider
Returns:
the new KeyGenerator object
Throws: NoSuchAlgorithmException
if a key generator for the requested algorithm is not available from the provider
Throws: NoSuchProviderException
if the requested provider is not available
See Also:
java.security.Provider
 o getProvider
public final Provider getProvider()
Returns the provider of this KeyGenerator object.

Returns:
the provider of this KeyGenerator object
 o init
public final void init(SecureRandom random)
Initializes the key generator.

Parameters:
random - the source of randomness for this generator
 o init
public final void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
Initializes the key generator with the specified parameter set, using a system-provided source of randomness.

Parameters:
params - the key generation parameters
Throws: InvalidAlgorithmParameterException
if the given parameters are inappropriate for this key generator
 o init
public final void init(AlgorithmParameterSpec params,
                       SecureRandom random) throws InvalidAlgorithmParameterException
Initializes the key generator with the specified parameter set and a user-provided source of randomness.

Parameters:
params - the key generation parameters
random - the source of randomness for this key generator
Throws: InvalidAlgorithmParameterException
if params is inappropriate for this key generator
 o generateKey
public final SecretKey generateKey()
Generates a secret key.

Returns:
the new key

All Packages  Class Hierarchy  This Package  Previous  Next  Index