Package com.digicert.validation.random
Class BasicRandomValueGenerator
java.lang.Object
com.digicert.validation.random.BasicRandomValueGenerator
- All Implemented Interfaces:
RandomValueGenerator
A basic implementation of the
RandomValueGenerator
interface that generates random alphanumeric strings.
This class uses a secure random number generator to produce random strings composed of alphanumeric characters.
It is designed to provide a simple and effective way to generate random values for various purposes, such as tokens, passwords, or other unique identifiers.
The generated strings are of a fixed length and are created using a specified character set.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
The charset used for generating random strings. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for BasicRandomValueGenerator. -
Method Summary
Modifier and TypeMethodDescriptionGenerates a random alphanumeric string of length 32.private String
generateString
(String charset, int length) Generates a random string of the specified length using the given charset.Returns the charset used for generating random strings.
-
Field Details
-
ALPHANUMERIC_CHARSET
The charset used for generating random strings.This string contains all the alphanumeric characters (digits 0-9, lowercase letters a-z, and uppercase letters A-Z). It serves as the pool of characters from which the random string will be generated.
- See Also:
-
-
Constructor Details
-
BasicRandomValueGenerator
public BasicRandomValueGenerator()Default constructor for BasicRandomValueGenerator.
-
-
Method Details
-
getCharset
Returns the charset used for generating random strings.- Specified by:
getCharset
in interfaceRandomValueGenerator
- Returns:
- A string representing the alphanumeric charset.
-
generateRandomString
Generates a random alphanumeric string of length 32.This method creates a random string composed of characters from the alphanumeric charset. The length of the generated string is fixed at 32 characters.
- Specified by:
generateRandomString
in interfaceRandomValueGenerator
- Returns:
- A randomly generated alphanumeric string.
-
generateString
Generates a random string of the specified length using the given charset.This method takes a charset and a length as parameters and produces a random string of the specified length. It uses a secure random number generator to select characters from the charset and build the string.
- Parameters:
charset
- The charset to use for generating the random string.length
- The length of the random string to generate.- Returns:
- A randomly generated string.
-