java.security
Class SecureRandom
java.lang.Object
|
+--java.util.Random
|
+--java.security.SecureRandom
public class
SecureRandomextends
RandomSecureRandom is the class interface for using SecureRandom
providers. It provides an interface to the SecureRandomSpi
engine so that programmers can generate pseudo-random numbers.
Author:- Mark Benvenuto <ivymccough@worldnet.att.net>
SecureRandom
public SecureRandom()
Default constructor for SecureRandom. It constructs a
new SecureRandom by instantating the first SecureRandom
algorithm in the default security provier.
It is not seeded and should be seeded using setSeed or else
on the first call to getnextBytes it will force a seed.
It is maintained for backwards compatibility and programs
should use getInstance.
SecureRandom
public SecureRandom(byte[] seed)
A constructor for SecureRandom. It constructs a new
SecureRandom by instantating the first SecureRandom algorithm
in the default security provier.
It is seeded with the passed function and is useful if the user
has access to hardware random device (like a radiation detector).
It is maintained for backwards compatibility and programs
should use getInstance.
Parameters:
SecureRandom
protected SecureRandom(java.security.SecureRandomSpi secureRandomSpi, java.security.Provider provider)
A constructor for SecureRandom. It constructs a new
SecureRandom using the specified SecureRandomSpi from
the specified security provier.
Parameters:
generateSeed
public byte[] generateSeed(int numBytes)
Returns the specified number of seed bytes.
Parameters:
Returns:
- an array containing the seed bytes
getInstance
public static SecureRandom getInstance(java.lang.String algorithm)
Returns an instance of a SecureRandom. It creates the class
for the specified algorithm if it exists from a provider.
Parameters:
Returns:
- Returns a new SecureRandom implmenting the chosen algorithm
Throws:
getInstance
public static SecureRandom getInstance(java.lang.String algorithm, java.lang.String provider)
Returns an instance of a SecureRandom. It creates the class
for the specified algorithm from the specified provider.
Parameters:
Returns:
- Returns a new SecureRandom implmenting the chosen algorithm
Throws:
getInstance
public static SecureRandom getInstance(java.lang.String algorithm, java.security.Provider provider)
Returns an instance of a SecureRandom. It creates the class for
the specified algorithm from the given provider.
Parameters:
Throws:
getProvider
public final Provider getProvider()
Returns the provider being used by the current SecureRandom class.
Returns:
- The provider from which this SecureRandom was attained
getSeed
public static byte[] getSeed(int numBytes)
Returns the given number of seed bytes. This method is
maintained only for backwards capability.
Parameters:
Returns:
- an array containing the seed bytes
next
protected final int next(int numBits)
Generates an integer containing the user specified
number of random bits. It is right justified and padded
with zeros.
Parameters:
Returns:
nextBytes
public void nextBytes(byte[] bytes)
Generates a user specified number of bytes. This function
is the basis for all the random functions.
Parameters:
setSeed
public void setSeed(byte[] seed)
Seeds the SecureRandom. The class is re-seeded for each call and
each seed builds on the previous seed so as not to weaken security.
Parameters:
setSeed
public void setSeed(long seed)
Seeds the SecureRandom. The class is re-seeded for each call and
each seed builds on the previous seed so as not to weaken security.
Parameters: