|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.crowd.util.SecureRandomStringUtils
public class SecureRandomStringUtils
Generates random String
s by selecting characters from
an alphabet using a cryptographically secure PRNG.
Methods on this class are thread-safe.
Method Summary | |
---|---|
static SecureRandomStringUtils |
getInstance()
|
String |
randomAlphanumericString(int length)
Generates a random String by randomly selecting characters from the the
alphabet of characters in the range 0-9, A-Z and a-z. |
String |
randomString(int length,
char[] alphabet)
Generates a random String by randomly selecting characters from
the provided alphabet until the desired length is reached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static SecureRandomStringUtils getInstance()
SecureRandomStringUtils
.public String randomString(int length, char[] alphabet)
String
by randomly selecting characters from
the provided alphabet
until the desired length
is reached.
The method for selecting a random character is specified by the implementation.
Unicode surrogate-pairing is not supported. All the provided characters should be
in the Unicode BMP, if you wish to avoid generating Strings with invalid UTF-16
surrogates.
length
- desired length of random String
. Must be positive.alphabet
- collection of characters to select from. Must contain at least one character.
String
of length length
, composed of characters from the supplied alphabet
.public String randomAlphanumericString(int length)
String
by randomly selecting characters from the the
alphabet of characters in the range 0-9, A-Z and a-z.
The method for selecting a random character is specified by the implementation.
length
- desired length of random String
.
String
of length length
.randomString(int, char[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |