[ Web Proxy ]
URL:
Viewing: https://developer.android.com/reference/kotlin/java/security/AlgorithmParameterGenerator [Back]  [Original]

AlgorithmParameterGenerator  |  API reference  |  Android Developers Skip to main content
Essentials Design & Plan Develop Google Play Blog
Search:
Android Studio
Android Developers [Android Developers]
Stay organized with collections Save and categorize content based on your preferences.
Added in API level 1

AlgorithmParameterGenerator

open class AlgorithmParameterGenerator
kotlin.Any
java.security.AlgorithmParameterGenerator

The AlgorithmParameterGenerator class is used to generate a set of parameters to be used with a certain algorithm. Parameter generators are constructed using the getInstance factory methods (static methods that return instances of a given class).

The object that will generate the parameters can be initialized in two different ways: in an algorithm-independent manner, or in an algorithm-specific manner:

In case the client does not explicitly initialize the AlgorithmParameterGenerator (via a call to an init method), each provider must supply (and document) a default initialization. However, note that defaults may vary across different providers. Additionally, the default value for a provider may change in a future version. Therefore, it is recommended to explicitly initialize the AlgorithmParameterGenerator instead of relying on provider-specific defaults.

Android provides the following AlgorithmParameterGenerator algorithms:

Algorithm Supported API Levels
AES 1-8
DES 1-8
DESede 1-8
DH 1+
DSA 1+

Summary

Protected constructors

Creates an AlgorithmParameterGenerator object.

Public methods
AlgorithmParameters!

Generates the parameters.

String!

Returns the standard name of the algorithm this parameter generator is associated with.

open static AlgorithmParameterGenerator!
getInstance(algorithm: String!)

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

open static AlgorithmParameterGenerator!
getInstance(algorithm: String!, provider: String!)

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

open static AlgorithmParameterGenerator!
getInstance(algorithm: String!, provider: Provider!)

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

Provider!

Returns the provider of this algorithm parameter generator object.

Unit
init(size: Int)

Initializes this parameter generator for a certain size.

Unit
init(size: Int, random: SecureRandom!)

Initializes this parameter generator for a certain size and source of randomness.

Unit
init(genParamSpec: AlgorithmParameterSpec!)

Initializes this parameter generator with a set of algorithm-specific parameter generation values.

Unit
init(genParamSpec: AlgorithmParameterSpec!, random: SecureRandom!)

Initializes this parameter generator with a set of algorithm-specific parameter generation values.

Protected constructors

AlgorithmParameterGenerator

Added in API level 1
protected AlgorithmParameterGenerator(
    paramGenSpi: AlgorithmParameterGeneratorSpi!,
    provider: Provider!,
    algorithm: String!)

Creates an AlgorithmParameterGenerator object.

Parameters
paramGenSpi AlgorithmParameterGeneratorSpi!: the delegate
provider Provider!: the provider
algorithm String!: the algorithm

Public methods

generateParameters

Added in API level 1
fun generateParameters(): AlgorithmParameters!

Generates the parameters.

Return
AlgorithmParameters! the new AlgorithmParameters object.

getAlgorithm

Added in API level 1
fun getAlgorithm(): String!

Returns the standard name of the algorithm this parameter generator is associated with.

Return
String! the string name of the algorithm.

getInstance

Added in API level 1
open static fun getInstance(algorithm: String!): AlgorithmParameterGenerator!

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

This method traverses the list of registered security Providers, starting with the most preferred Provider. A new AlgorithmParameterGenerator object encapsulating the AlgorithmParameterGeneratorSpi 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 String!: the name of the algorithm this parameter generator is associated with.cc
Return
AlgorithmParameterGenerator! the new AlgorithmParameterGenerator object
Exceptions
java.lang.NullPointerException if algorithm is null on Android 14 or above
java.security.NoSuchAlgorithmException if no Provider supports an AlgorithmParameterGeneratorSpi implementation for the specified algorithm

See Also

getInstance

Added in API level 1
open static fun getInstance(
    algorithm: String!,
    provider: String!
): AlgorithmParameterGenerator!

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

A new AlgorithmParameterGenerator object encapsulating the AlgorithmParameterGeneratorSpi 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 String!: the name of the algorithm this parameter generator is associated with.
provider String!: the string name of the Provider.
Return
AlgorithmParameterGenerator! the new AlgorithmParameterGenerator object
Exceptions
java.lang.IllegalArgumentException if the provider name is null or empty
java.lang.NullPointerException if algorithm is null on Android 14 or above
java.security.NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi implementation for the specified algorithm is not available from the specified provider
java.security.NoSuchProviderException if the specified provider is not registered in the security provider list

See Also

getInstance

Added in API level 1
open static fun getInstance(
    algorithm: String!,
    provider: Provider!
): AlgorithmParameterGenerator!

Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.

A new AlgorithmParameterGenerator object encapsulating the AlgorithmParameterGeneratorSpi 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 String!: the string name of the algorithm this parameter generator is associated with.
provider Provider!: the Provider object.
Return
AlgorithmParameterGenerator! the new AlgorithmParameterGenerator object
Exceptions
java.lang.IllegalArgumentException if the specified provider is null
java.lang.NullPointerException if algorithm is null on Android 14 or above
java.security.NoSuchAlgorithmException if an AlgorithmParameterGeneratorSpi implementation for the specified algorithm is not available from the specified Provider object

See Also

getProvider

Added in API level 1
fun getProvider(): Provider!

Returns the provider of this algorithm parameter generator object.

Return
Provider! the provider of this algorithm parameter generator object

init

Added in API level 1
fun init(size: Int): Unit

Initializes this parameter generator for a certain size. To create the parameters, the SecureRandom implementation of the highest-priority installed provider is used as the source of randomness. (If none of the installed providers supply an implementation of SecureRandom, a system-provided source of randomness is used.)

Parameters
size Int: the size (number of bits).

init

Added in API level 1
fun init(
    size: Int,
    random: SecureRandom!
): Unit

Initializes this parameter generator for a certain size and source of randomness.

Parameters
size Int: the size (number of bits).
random SecureRandom!: the source of randomness.

init

Added in API level 1
fun init(genParamSpec: AlgorithmParameterSpec!): Unit

Initializes this parameter generator with a set of algorithm-specific parameter generation values. To generate the parameters, the SecureRandom implementation of the highest-priority installed provider is used as the source of randomness. (If none of the installed providers supply an implementation of SecureRandom, a system-provided source of randomness is used.)

Parameters
genParamSpec AlgorithmParameterSpec!: the set of algorithm-specific parameter generation values.
Exceptions
java.security.InvalidAlgorithmParameterException if the given parameter generation values are inappropriate for this parameter generator.

init

Added in API level 1
fun init(
    genParamSpec: AlgorithmParameterSpec!,
    random: SecureRandom!
): Unit

Initializes this parameter generator with a set of algorithm-specific parameter generation values.

Parameters
genParamSpec AlgorithmParameterSpec!: the set of algorithm-specific parameter generation values.
random SecureRandom!: the source of randomness.
Exceptions
java.security.InvalidAlgorithmParameterException if the given parameter generation values are inappropriate for this parameter generator.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-13 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-02-13 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page