Android
java.security
public class

java.security.SecureRandom

java.lang.Object
java.util.Random Serializable
java.security.SecureRandom

Summary

Public Constructors

            SecureRandom()
Constructs a new instance of this class.
            SecureRandom(byte[] seed)
Constructs a new instance of this class.

Protected Constructors

            SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider)

Public Methods

          byte[]  generateSeed(int numBytes)
Generates a certain number of seed bytes
          String  getAlgorithm()
      static    SecureRandom  getInstance(String algorithm, String provider)
Returns a new SecureRandom which is capable of running the algorithm described by the argument.
      static    SecureRandom  getInstance(String algorithm, Provider provider)
      static    SecureRandom  getInstance(String algorithm)
    final      Provider  getProvider()
Returns the Provider of the secure random represented by the receiver.
      static    byte[]  getSeed(int numBytes)
Returns the given number of seed bytes, computed using the seed generation algorithm used by this class.
  synchronized        void  nextBytes(byte[] bytes)
Modifies the byte array by a random sequence of bytes generated by this random number generator.
  synchronized        void  setSeed(byte[] seed)
          void  setSeed(long seed)
Reseeds this random object with the eight bytes described by the representation of the long provided.

Protected Methods

    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.
Methods inherited from class java.util.Random
Methods inherited from class java.lang.Object

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

protected SecureRandom(SecureRandomSpi secureRandomSpi, Provider provider)

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 String getAlgorithm()

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.

Throws

NoSuchAlgorithmException If the algorithm cannot be found
NoSuchProviderException

public static SecureRandom getInstance(String algorithm, Provider provider)

public static SecureRandom getInstance(String algorithm)

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
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56