public class SecureRandom extends Random
| Constructor and Description |
|---|
SecureRandom() |
SecureRandom(byte[] seed) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
generateSeed(int numBytes) |
protected int |
next(int numBits)
Generates an integer containing the user specified
number of random bits.
|
void |
nextBytes(byte[] bytes)
Fills an array of bytes with random numbers.
|
void |
setSeed(byte[] seed) |
void |
setSeed(long seed)
Seeds the SecureRandom.
|
nextBoolean, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLongpublic void setSeed(byte[] seed)
public void setSeed(long seed)
public void nextBytes(byte[] bytes)
Randompublic void nextBytes(byte[] bytes)
{
for (int i = 0; i < bytes.length; i += 4)
{
int random = next(32);
for (int j = 0; i + j < bytes.length && j < 4; j++)
{
bytes[i+j] = (byte) (random & 0xff)
random >>= 8;
}
}
}public byte[] generateSeed(int numBytes)