Package org.cryptacular.generator
Class RandomIdGenerator
java.lang.Object
org.cryptacular.generator.RandomIdGenerator
- All Implemented Interfaces:
IdGenerator
Generates random identifiers with an alphanumeric character set by default.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringIdentifier character set.static final StringDefault character set.private final intSize of generated identifiers.private static final intMaximum length of ID to generate in bytes.private final SecureRandomSource of randomness. -
Constructor Summary
ConstructorsConstructorDescriptionRandomIdGenerator(int length) Creates a new instance with the default character set.RandomIdGenerator(int length, String charset) Creates a new instance with a defined character set. -
Method Summary
-
Field Details
-
DEFAULT_CHARSET
Default character set.- See Also:
-
MAX_ID_LENGTH
private static final int MAX_ID_LENGTHMaximum length of ID to generate in bytes. -
length
private final int lengthSize of generated identifiers. -
charset
Identifier character set. -
secureRandom
Source of randomness.
-
-
Constructor Details
-
RandomIdGenerator
public RandomIdGenerator(int length) Creates a new instance with the default character set.- Parameters:
length- Number of characters in generated identifiers.
-
RandomIdGenerator
Creates a new instance with a defined character set.- Parameters:
length- Number of characters in generated identifiers.charset- Character set.
-
-
Method Details
-
generate
Description copied from interface:IdGeneratorGenerates a random identifier.- Specified by:
generatein interfaceIdGenerator- Returns:
- Random identifier.
-