public class RandomIdent extends Object implements IdentValue
This class contains the random number and the encoded representations for a single ident.
This class is immutable.
Constructor and Description |
---|
RandomIdent(String ident,
int randomSize,
Random rng,
Set<EncodingConfig> encodings)
Create a new
RandomIdent and the random number for the ident . |
Modifier and Type | Method and Description |
---|---|
String |
getEncoded(EncodingConfig encoding)
Return the random number in the given
encoding . |
String |
getIdent()
Return the ident number.
|
byte[] |
getValue()
Return the raw random number generated.
|
public RandomIdent(String ident, int randomSize, Random rng, Set<EncodingConfig> encodings)
Create a new RandomIdent
and the random number for the ident
. The random number has a size of
randomSize
bits (rounded down to the next whole byte). For the generation of the random number the given
rng
will be used. The generated random number will be encoded in all given encodings
.
For high quality random numbers use an appropriate random number generator
(e.g. SecureRandom
).
ident
- the ident for which the random number will be generated for.randomSize
- the size in bits (rounded down to the next byte).rng
- the random number generator to use.encodings
- the encodings that are used for the encoded representation of the random number.IllegalArgumentException
- if no encoder for a given encoding can be found.public String getIdent()
Return the ident number.
getIdent
in interface IdentValue
public byte[] getValue()
Return the raw random number generated.
getValue
in interface IdentValue
public String getEncoded(EncodingConfig encoding)
Return the random number in the given encoding
. Only the encodings that were given during construction
can be returned.
getEncoded
in interface IdentValue
encoding
- the encoding for which the encoded value should be returned.null
if the encoding is unknown.Copyright © 2020 sw4j.org. All rights reserved.