javax.crypto
public class KeyGenerator extends Object
Since: 1.4
Constructor Summary | |
---|---|
protected | KeyGenerator(KeyGeneratorSpi kgSpi, Provider provider, String algorithm)
Create a new key generator.
|
Method Summary | |
---|---|
SecretKey | generateKey()
Generate a key.
|
String | getAlgorithm()
Return the name of this key generator.
|
static KeyGenerator | getInstance(String algorithm)
Create a new key generator, returning the first available implementation.
|
static KeyGenerator | getInstance(String algorithm, String provider)
Create a new key generator from the named provider.
|
static KeyGenerator | getInstance(String algorithm, Provider provider)
Create a new key generator from the supplied provider.
|
Provider | getProvider()
Return the provider of the underlying implementation.
|
void | init(AlgorithmParameterSpec params)
Initialize this key generator with a set of parameters; the
highest-priority {@link java.security.SecureRandom} implementation
will be used.
|
void | init(AlgorithmParameterSpec params, SecureRandom random)
Initialize this key generator with a set of parameters and a source
of randomness.
|
void | init(int keySize)
Initialize this key generator with a key size (in bits); the
highest-priority {@link java.security.SecureRandom} implementation
will be used.
|
void | init(int keySize, SecureRandom random)
Initialize this key generator with a key size (in bits) and a
source of randomness.
|
void | init(SecureRandom random)
Initialize this key generator with a source of randomness. |
Parameters: kgSpi The underlying generator. provider The provider of this implementation. algorithm The algorithm's name.
Returns: The new key.
Returns: The algorithm name.
Parameters: algorithm The generator algorithm name.
Throws: NoSuchAlgorithmException If the specified algorithm does not exist. IllegalArgumentException if algorithm
is
null
or is an empty string.
Parameters: algorithm The generator algorithm name. provider The name of the provider to use.
Returns: An appropriate key generator, if found.
Throws: NoSuchAlgorithmException If the specified algorithm is not
implemented by the named provider. NoSuchProviderException If the named provider does not exist. IllegalArgumentException if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.
Parameters: algorithm The generator algorithm name. provider The provider to use.
Returns: An appropriate key generator, if found.
Throws: NoSuchAlgorithmException If the specified algorithm is not
implemented by the provider. IllegalArgumentException if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.
Returns: The provider.
Parameters: params The algorithm parameters.
Throws: java.security.InvalidAlgorithmParameterException If the supplied parameters are inapproprate.
Parameters: params The algorithm parameters. random The source of randomness.
Throws: java.security.InvalidAlgorithmParameterException If the supplied parameters are inapproprate.
Parameters: keySize The target key size, in bits.
Throws: java.security.InvalidParameterException If the key size is unsupported.
Parameters: keySize The target key size, in bits. random The source of randomness.
Throws: java.security.InvalidAlgorithmParameterException If the key size is unsupported.
Parameters: random The source of randomness.