|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Randomizer
The Randomizer interface defines a set of methods for creating cryptographically random numbers and strings. Implementers should be sure to use a strong cryptographic implementation, such as the JCE or BouncyCastle. Weak sources of randomness can undermine a wide variety of security mechanisms. The specific algorithm used is configurable in ESAPI.properties.
Method Summary | |
---|---|
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. |
Method Detail |
---|
String getRandomString(int length, char[] characterSet)
length
- the length of the stringcharacterSet
- the set of characters to include in the created random string
boolean getRandomBoolean()
int getRandomInteger(int min, int max)
min
- the minimum integer that will be returnedmax
- the maximum integer that will be returned
long getRandomLong()
String getRandomFilename(String extension)
extension
- extension to add to the random filename
float getRandomReal(float min, float max)
min
- the minimum real number that will be returnedmax
- the maximum real number that will be returned
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.
EncryptionException
- if hashing or encryption failsbyte[] getRandomBytes(int n)
n
- The requested number of random bytes.
n
random bytes are returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |