public class DefaultRandomizer extends Object implements Randomizer
Randomizer
Modifier and Type | Method and Description |
---|---|
static Randomizer |
getInstance() |
boolean |
getRandomBoolean()
Returns a random boolean.
|
byte[] |
getRandomBytes(int n)
Generates a specified number of random bytes.
|
String |
getRandomFilename(String extension)
Returns an unguessable random filename with the specified extension.
|
String |
getRandomGUID()
Generates a random GUID.
|
int |
getRandomInteger(int min,
int max)
Gets the random integer.
|
long |
getRandomLong()
Gets the random long.
|
float |
getRandomReal(float min,
float max)
Gets the random real.
|
String |
getRandomString(int length,
char[] characterSet)
Gets a random string of a desired length and character set.
|
public static Randomizer getInstance()
public String getRandomString(int length, char[] characterSet)
getRandomString
in interface Randomizer
length
- the length of the stringcharacterSet
- the set of characters to include in the created random stringpublic boolean getRandomBoolean()
getRandomBoolean
in interface Randomizer
public int getRandomInteger(int min, int max)
getRandomInteger
in interface Randomizer
min
- the minimum integer that will be returnedmax
- the maximum integer that will be returnedpublic long getRandomLong()
getRandomLong
in interface Randomizer
public float getRandomReal(float min, float max)
getRandomReal
in interface Randomizer
min
- the minimum real number that will be returnedmax
- the maximum real number that will be returnedpublic String getRandomFilename(String extension)
getRandomFilename
in interface Randomizer
extension
- extension to add to the random filenamepublic String getRandomGUID() throws EncryptionException
For more information including algorithms used to create UUIDs, see the Internet-Draft UUIDs and GUIDs or the standards body definition at ISO/IEC 11578:1996.
getRandomGUID
in interface Randomizer
EncryptionException
- if hashing or encryption failspublic byte[] getRandomBytes(int n)
getRandomBytes
in interface Randomizer
n
- The requested number of random bytes.n
random bytes are returned.Copyright © 2016 The Open Web Application Security Project (OWASP). All rights reserved.