Provides a basic API for using cryptographically strong pseudo random number generation algorithms.

Package overview

Random number generators, used in cryptography, are based on algorithms which output sequences of statically independent and unbiased bits.

The following diagram shows the important classes participating in this package:

The following example shows how to instantiate, use, and clone a PRNG based on the RC4 stream cipher algorithm.

byte[] b1 = new byte[16];
byte[] b2 = new byte[16];
HashMap attrib = new HashMap();
attrib.put(ARCFour.ARCFOUR_KEY_MATERIAL, new byte[0]);

IRandom r1 = PRNGFactory.getInstance(Registry.ARCFOUR_PRNG);
r1.init(attrib);
r1.nextBytes(b1, 0, b1.length);

IRandom r2 = (IRandom) r1.clone();

r1.nextBytes(b1, 0, b1.length);
r2.nextBytes(b2, 0, b1.length);