Search code examples
windowsboostportabilitynon-deterministicrandom

Non-Linux Implementations of boost::random_device


Currently, Boost only implements the random_device class for Linux (maybe *nix) systems. Does anyone know of existing implementations for other OS-es? Ideally, these implementations would be open-source.

If none exist, how should I go about implementing a non-deterministic RNG for Windows as well as Mac OS X? Do API calls exist in either environment that would provide this functionality? Thanks (and sorry for all the questions)!


Solution

  • On MacOSX, you can use /dev/random (since it's a *nix).

    On Windows, you probably want the CryptGenRandom function. I don't know if there's an implementation of boost::random_device that uses it.