java.lang.Object | ||
↳ | java.security.SecureRandomSpi | |
↳ | sun.security.provider.SecureRandom |
This class provides a crytpographically strong pseudo-random number generator based on the SHA-1 hash algorithm.
Note that if a seed is not provided, we attempt to provide sufficient seed bytes to completely randomize the internal state of the generator (20 bytes). However, our seed generation algorithm has not been thoroughly studied or widely deployed.
Also note that when a random object is deserialized, engineNextBytes invoked on the restored random object will yield the exact same (random) bytes as the original object. If this behaviour is not desired, the restored random object should be seeded, using engineSetSeed.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This empty constructor automatically seeds the generator.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the given number of seed bytes, computed using the seed
generation algorithm that this class uses to seed itself.
| |||||||||||
Generates a user-specified number of random bytes.
| |||||||||||
Reseeds this random object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
This empty constructor automatically seeds the generator. We attempt to provide sufficient seed bytes to completely randomize the internal state of the generator (20 bytes). Note, however, that our seed generation algorithm has not been thoroughly studied or widely deployed.
The first time this constructor is called in a given Virtual Machine, it may take several seconds of CPU time to seed the generator, depending on the underlying hardware. Successive calls run quickly because they rely on the same (internal) pseudo-random number generator for their seed bits.
Returns the given number of seed bytes, computed using the seed generation algorithm that this class uses to seed itself. This call may be used to seed other random number generators. While we attempt to return a "truly random" sequence of bytes, we do not know exactly how random the bytes returned by this call are. (See the empty constructor SecureRandom for a brief description of the underlying algorithm.) The prudent user will err on the side of caution and get extra seed bytes, although it should be noted that seed generation is somewhat costly.
numBytes | the number of seed bytes to generate. |
---|
Generates a user-specified number of random bytes.
result | the array to be filled in with random bytes. |
---|
Reseeds this random object. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness.
seed | the seed. |
---|