Package org.keycloak.common.util
Class SecretGenerator
java.lang.Object
org.keycloak.common.util.SecretGenerator
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]
static final char[]
static final int
static final int
static final int
static final char[]
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
equivalentEntropySize
(int byteLengthEntropy, int dstAlphabetLeng) Returns the equivalent length for a destination alphabet to have the same entropy bits than a byte array random generated.static int
equivalentEntropySize
(int length, int srcAlphabetLength, int dstAlphabetLeng) Returns the equivalent length for a destination alphabet to have the same entropy bits than another source alphabet.static SecretGenerator
byte[]
byte[]
randomBytes
(int length) randomString
(int length) randomString
(int length, char[] symbols)
-
Field Details
-
SECRET_LENGTH_256_BITS
public static final int SECRET_LENGTH_256_BITS- See Also:
-
SECRET_LENGTH_384_BITS
public static final int SECRET_LENGTH_384_BITS- See Also:
-
SECRET_LENGTH_512_BITS
public static final int SECRET_LENGTH_512_BITS- See Also:
-
UPPER
public static final char[] UPPER -
DIGITS
public static final char[] DIGITS -
ALPHANUM
public static final char[] ALPHANUM
-
-
Method Details
-
getInstance
-
randomString
-
randomString
-
randomString
-
randomBytes
public byte[] randomBytes() -
randomBytes
public byte[] randomBytes(int length) -
equivalentEntropySize
public static int equivalentEntropySize(int byteLengthEntropy, int dstAlphabetLeng) Returns the equivalent length for a destination alphabet to have the same entropy bits than a byte array random generated.- Parameters:
byteLengthEntropy
- The desired entropy in bytesdstAlphabetLeng
- The length of the destination alphabet- Returns:
- The equivalent length in destination alphabet to have the same entropy bits
-
equivalentEntropySize
public static int equivalentEntropySize(int length, int srcAlphabetLength, int dstAlphabetLeng) Returns the equivalent length for a destination alphabet to have the same entropy bits than another source alphabet.- Parameters:
length
- The length of the string encoded in source alphabetsrcAlphabetLength
- The length of the source alphabetdstAlphabetLeng
- The length of the destination alphabet- Returns:
- The equivalent length (same entropy) in destination alphabet for a string of length in source alphabet
-