C++11 Header-only CSPRNG layer
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.appveyor.yml
.gitmodules
.travis.yml
LICENSE
README.md
osrandom.hpp

README.md

OSRandom TravisCI_badge AppVeyor_badge

C++11 header-only OS Random Layer

A header-only random layer that expose cryptographically secure pseudorandom number generators (CSPRNG) provided by OS:

Prerequisites

  • Linux, *nix, BSD ...
    • C++11 compiler
    • /dev/random is available to read
      This means API will block when there are not enough entropy in system
  • Windows
    • C++11 compiler
    • Warning: NOMINMAX is already defined and included before Windows.h header
      I.e. If you include Windows.h before this library, make sure NOMINMAX is defined before Windows.h
  • Run tests

Usage

To use this header in your project:

  1. Download osrandom.hpp

  2. Use it like:

    #include <random>
    #include "osrandom.hpp"
    
    void example()
    {
      // Specify distribution of outputs
      std::uniform_int_distribution<> dist;
    
      // Get an instance...
      Chocobo1::OSRandom osRandom;
    
      // Voilà!
      int number = dist(osRandom);
    
      // Or you prefer accessing it directly
      int number2 = osRandom();
    }

Run Tests

To run tests, execute:

git submodule update --init --remote --recursive

cd test

# linux
make
./run_tests

# Windows
build.bat
run_tests.exe

License

See LICENSE file