net.rim.device.api.crypto
Class RandomSource
java.lang.Object
net.rim.device.api.crypto.RandomSource
public final class RandomSource
- extends Object
A random number generator that generates cryptographically random bytes. The
random bytes are used in the generation of keys and for other cryptographic operations.
Random bits are continually harvested from the system and pooled for future
use.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
Method Summary |
|
static void |
add(Object obj)
Adds the cryptographic hash of a deep scan of the given object to the
pool of randomness (ie the contents of the object, and anything it references,
will be hashed). |
|
static void |
getBytes(byte[] buffer)
Generates random bytes, filling the given buffer entirely. |
|
static void |
getBytes(byte[] buffer,
int offset,
int length)
Inserts random bytes into the given buffer starting at the
specified array index offset. |
|
static byte[] |
getBytes(int length)
Generates a specified length of random bytes, returning them as a byte
array of the specified size. |
|
static int |
getInt()
Returns a random integer. |
|
static int |
getInt(int num)
Returns a random non-negative integer modulo. |
|
static long |
getLong()
Returns a random long integer. |
|
static long |
getLong(long num)
Returns a random non-negative long integer modulo. |
getLong
public static long getLong()
- Returns a random long integer.
- Returns:
- A random value of type
long
. - Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getInt
public static int getInt()
- Returns a random integer.
- Returns:
- A random value of type
int
. - Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getLong
public static long getLong(long num)
- Returns a random non-negative long integer modulo.
- Parameters:
num
- A positive modulus num
. The random long integer
returned will be in the range 0..num-1
, inclusive.
- Returns:
- A random value of type
long
. - Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getInt
public static int getInt(int num)
- Returns a random non-negative integer modulo.
- Parameters:
num
- A positive modulus num
. The random integer
returned will be in the range 0..num-1
, inclusive.
- Returns:
- A random value of type
int
. - Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getBytes
public static void getBytes(byte[] buffer,
int offset,
int length)
- Inserts random bytes into the given buffer starting at the
specified array index offset.
- Parameters:
buffer
- The buffer to store the random bytes.offset
- The start, or initial position, of the data within the buffer.length
- The number of random bytes to store.- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getBytes
public static byte[] getBytes(int length)
- Generates a specified length of random bytes, returning them as a byte
array of the specified size.
- Parameters:
length
- The number of random bytes to generate.
- Returns:
- A byte array containing the random bytes.
- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
getBytes
public static void getBytes(byte[] buffer)
- Generates random bytes, filling the given buffer entirely.
- Parameters:
buffer
- The byte array to fill with random bytes.- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
add
public static void add(Object obj)
- Adds the cryptographic hash of a deep scan of the given object to the
pool of randomness (ie the contents of the object, and anything it references,
will be hashed).
- Parameters:
obj
- The object whose hash is to be added to the pool of randomness.- Category:
- Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
- Since:
- BlackBerry API 3.6.0
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal