public class RandomUtils
extends java.lang.Object
This class contains a variety of utility static methods that deal in Random numbers for use in Ganymede.
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
charsetA |
private static java.lang.String |
charsetAN |
private static java.lang.String |
charsetC |
private static java.util.Random |
randomizer |
private static java.security.SecureRandom |
secureRandomizer |
| Constructor and Description |
|---|
RandomUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getRandomHex()
This method returns a random 32 bit hex string, used to ensure
that a string including it is random.
|
static java.lang.String |
getRandomPassword(int length)
Get a random password, using all characters, length chars long
|
static java.lang.String |
getRandomString(int length,
java.lang.String charset)
Get a random string, using all characters from given charset,
length chars long
|
static java.lang.String |
getRandomUsername()
Get a random username, 8 characters alpha-numeric, starting with
an alphabetic character.
|
static java.lang.String |
getSaltedString(java.lang.String in)
This method takes a string, adds a random salt to it, and returns
it.
|
static void |
main(java.lang.String[] args)
Test rig
|
private static java.util.Random randomizer
private static java.security.SecureRandom secureRandomizer
private static final java.lang.String charsetA
private static final java.lang.String charsetAN
private static final java.lang.String charsetC
public static java.lang.String getRandomHex()
This method returns a random 32 bit hex string, used to ensure that a string including it is random.
The random number generator for this method is low security, and should not be used for cryptographic purposes where unpredictability is paramount.
public static java.lang.String getSaltedString(java.lang.String in)
This method takes a string, adds a random salt to it, and returns it.
The random number generator for this method is low security, and should not be used for cryptographic purposes where unpredictability is paramount.
Generally, salts need not be unpredictable, as long as they are not often repeated.
public static java.lang.String getRandomString(int length,
java.lang.String charset)
public static java.lang.String getRandomUsername()
public static java.lang.String getRandomPassword(int length)
public static void main(java.lang.String[] args)