The XInt Random Number System

The library includes two convenience classes, meant to be used with the xint::random_prime function.

default_random_generator is a thin shell around one of the faster pseudo-random generators provided by Boost.Random. It does not produce secure random numbers, but is often all that is needed.

strong_random_generator provides an interface to the operating system's secure random number generator, for both Windows and UNIX-derived systems. It will throw an exception of type no_strong_random if you try to instantiate it on a system that does not have an operating-system-supplied generator. Note that, as of Boost 1.43, the boost::random_device class is basically identical to xint::strong_random_generator, and probably better in some respects. xint::strong_random_generator is still provided because boost::random_device requires a compiled library, making it more difficult to use in examples.

If you have a different preferred generator, perhaps one that interfaces with dedicated hardware to produce randomness, you can plug that into the library's random_by_size and random_prime functions instead.

See the code at the top of the Prime Numbers page for an example of how to use these generators to produce secure prime numbers.


© Copyright Chad Nelson, 2010-2011. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)