java.security
public
class
java.security.SecureRandom
Summary
Public Constructors
Protected Constructors
Public Methods
Protected Methods
|
|
final |
|
|
int |
next(int numBits) |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
public
SecureRandom()
Constructs a new instance of this class. Users are encouraged to use
getInstance()
instead.
An implementation for the highest-priority provider is returned. The
instance returned will not have been seeded.
public
SecureRandom(byte[] seed)
Constructs a new instance of this class. Users are encouraged to use
getInstance()
instead.
An implementation for the highest-priority provider is returned. The
instance returned will be seeded with the parameter.
Parameters
seed
| bytes forming the seed for this generator.
|
Protected Constructors
Public Methods
public
byte[]
generateSeed(int numBytes)
Generates a certain number of seed bytes
Parameters
numBytes
| int Number of seed bytes to generate |
Returns
- byte[] The seed bytes generated
public
static
SecureRandom
getInstance(String algorithm, String provider)
Returns a new SecureRandom which is capable of running the algorithm
described by the argument. The result will be an instance of a subclass
of SecureRandomSpi which implements that algorithm.
Parameters
algorithm
| java.lang.String Name of the algorithm desired |
provider
| java.security.Provider Provider which has to implement the
algorithm |
Returns
- SecureRandom a concrete implementation for the algorithm desired.
public
final
Provider
getProvider()
Returns the Provider of the secure random represented by the receiver.
Returns
- Provider an instance of a subclass of java.security.Provider
public
static
byte[]
getSeed(int numBytes)
Returns the given number of seed bytes, computed using the seed
generation algorithm used by this class.
Parameters
numBytes
| int the given number of seed bytes |
Returns
- byte[] The seed bytes generated
public
synchronized
void
nextBytes(byte[] bytes)
Modifies the byte array by a random sequence of bytes generated by this
random number generator.
Parameters
bytes
| non-null array to contain the new random bytes |
public
synchronized
void
setSeed(byte[] seed)
public
void
setSeed(long seed)
Reseeds this random object with the eight bytes described by the
representation of the long provided.
Parameters
seed
| long Number whose representation to use to reseed the
receiver.
|
Protected Methods
protected
final
int
next(int numBits)
Returns a pseudo-random uniformly distributed
int
value of
the number of bits specified by the argument
bits
as
described by Donald E. Knuth in
The Art of Computer Programming,
Volume 2: Seminumerical Algorithms, section 3.2.1.
Parameters
numBits
| number of bits of the returned value |
Returns
- int a pseudo-random generated int number