Professional Documents
Culture Documents
Overview Package
Class
https://docs.oracle.com/javase/7/docs/api/javax/...
Java Platform
Standard Ed. 7
Frames No Frames
javax.crypto
Class KeyGenerator
java.lang.Object
javax.crypto.KeyGenerator
These algorithms are described in the KeyGenerator section of the Java Cryptography Architecture Standard
Algorithm Name Documentation. Consult the release documentation for your implementation to see if any other
algorithms are supported.
Since:
1 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
1.4
See Also:
SecretKey
Constructor Summary
Constructors
Modifier
protected
KeyGenerator(KeyGeneratorSpikeyGenSpi, Providerprovider,
Stringalgorithm)
Method Summary
Methods
Modifier and Type
SecretKey
generateKey()
getAlgorithm()
getInstance(Stringalgorithm)
Returns a KeyGenerator object that generates secret keys for the specified
algorithm.
static KeyGenerator
getInstance(Stringalgorithm, Providerprovider)
Returns a KeyGenerator object that generates secret keys for the specified
algorithm.
static KeyGenerator
getInstance(Stringalgorithm, Stringprovider)
Returns a KeyGenerator object that generates secret keys for the specified
algorithm.
Provider
getProvider()
init(AlgorithmParameterSpecparams)
init(AlgorithmParameterSpecparams, SecureRandomrandom)
Initializes this key generator with the specified parameter set and a
user-provided source of randomness.
void
init(intkeysize)
init(intkeysize, SecureRandomrandom)
init(SecureRandomrandom)
2 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
wait
Constructor Detail
KeyGenerator
protectedKeyGenerator(KeyGeneratorSpikeyGenSpi,
Providerprovider,
Stringalgorithm)
Parameters:
keyGenSpi - the delegate
provider - the provider
algorithm - the algorithm
Method Detail
getAlgorithm
public finalStringgetAlgorithm()
Returns:
the algorithm name of this KeyGenerator object.
getInstance
public static finalKeyGeneratorgetInstance(Stringalgorithm)
throws NoSuchAlgorithmException
Returns a KeyGenerator object that generates secret keys for the specified algorithm.
This method traverses the list of registered security Providers, starting with the most preferred Provider.
A new KeyGenerator object encapsulating the KeyGeneratorSpi implementation from the first Provider
that supports the specified algorithm is returned.
Note that the list of registered providers may be retrieved via the Security.getProviders() method.
Parameters:
algorithm - the standard name of the requested key algorithm. See the KeyGenerator section in the
Java Cryptography Architecture Standard Algorithm Name Documentation for information about
standard algorithm names.
3 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
Returns:
the new KeyGenerator object.
Throws:
NullPointerException - if the specified algorithm is null.
NoSuchAlgorithmException - if no Provider supports a KeyGeneratorSpi implementation for the
specified algorithm.
See Also:
Provider
getInstance
public static finalKeyGeneratorgetInstance(Stringalgorithm,
Stringprovider)
throws NoSuchAlgorithmException,
NoSuchProviderException
Returns a KeyGenerator object that generates secret keys for the specified algorithm.
A new KeyGenerator object encapsulating the KeyGeneratorSpi implementation from the specified
provider is returned. The specified provider must be registered in the security provider list.
Note that the list of registered providers may be retrieved via the Security.getProviders() method.
Parameters:
algorithm - the standard name of the requested key algorithm. See the KeyGenerator section in the
Java Cryptography Architecture Standard Algorithm Name Documentation for information about
standard algorithm names.
provider - the name of the provider.
Returns:
the new KeyGenerator object.
Throws:
NullPointerException - if the specified algorithm is null.
NoSuchAlgorithmException - if a KeyGeneratorSpi implementation for the specified algorithm is not
See Also:
Provider
getInstance
public static finalKeyGeneratorgetInstance(Stringalgorithm,
Providerprovider)
throws NoSuchAlgorithmException
Returns a KeyGenerator object that generates secret keys for the specified algorithm.
4 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
A new KeyGenerator object encapsulating the KeyGeneratorSpi implementation from the specified
Provider object is returned. Note that the specified Provider object does not have to be registered in the
provider list.
Parameters:
algorithm - the standard name of the requested key algorithm. See the KeyGenerator section in the
Java Cryptography Architecture Standard Algorithm Name Documentation for information about
standard algorithm names.
provider - the provider.
Returns:
the new KeyGenerator object.
Throws:
NullPointerException - if the specified algorithm is null.
NoSuchAlgorithmException - if a KeyGeneratorSpi implementation for the specified algorithm is not
See Also:
Provider
getProvider
public finalProvidergetProvider()
Returns:
the provider of this KeyGenerator object
init
public finalvoidinit(SecureRandomrandom)
Parameters:
random - the source of randomness for this generator
init
public finalvoidinit(AlgorithmParameterSpecparams)
throws InvalidAlgorithmParameterException
5 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
Parameters:
params - the key generation parameters
Throws:
InvalidAlgorithmParameterException - if the given parameters are inappropriate for this key
generator
init
public finalvoidinit(AlgorithmParameterSpecparams,
SecureRandomrandom)
throws InvalidAlgorithmParameterException
Initializes this 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
init
public finalvoidinit(intkeysize)
Parameters:
keysize - the keysize. This is an algorithm-specific metric, specified in number of bits.
Throws:
InvalidParameterException - if the keysize is wrong or not supported.
init
public finalvoidinit(intkeysize,
SecureRandomrandom)
Initializes this key generator for a certain keysize, using a user-provided source of randomness.
Parameters:
keysize - the keysize. This is an algorithm-specific metric, specified in number of bits.
random - the source of randomness for this key generator
Throws:
6 de 7
01/11/16 23:43
https://docs.oracle.com/javase/7/docs/api/javax/...
generateKey
public finalSecretKeygenerateKey()
Returns:
the new key
Overview Package
Class
Java Platform
Standard Ed. 7
Frames No Frames
7 de 7
01/11/16 23:43