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 intstatic final intstatic final intstatic final char[] -
Method Summary
Modifier and TypeMethodDescriptionstatic intequivalentEntropySize(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 intequivalentEntropySize(int length, int srcAlphabetLength, int dstAlphabetLeng) Returns the equivalent length for a destination alphabet to have the same entropy bits than another source alphabet.Returns a pseudo-UUID where all bits are random to have a maximum entropy.static SecretGeneratorbyte[]byte[]randomBytes(int length) randomBytesHex(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
-
generateSecureID
-
randomString
-
randomString
-
randomString
-
randomBytes
public byte[] randomBytes() -
randomBytes
public byte[] randomBytes(int length) -
randomBytesHex
-
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
-
generateSecureUUID
Returns a pseudo-UUID where all bits are random to have a maximum entropy.- Returns:
- UUID with all bits random
-