/* Copyright (c) 2014 IOnU Security Inc. All rights reserved Created February 2014 by Kendrick Webster Random.h - header for random number generator */ #pragma once #include #include /* Simple/fast 'random' number source based on an entropy pool seeded by high-resolution timestamps. SeedRandom() should be called by I/O functions, event loops, etc. */ namespace ionu { namespace random { // get 'random' bytes from this module's RNG void GetRandom(void* p, size_t n); // fill with random bytes template void Random(T& v) {GetRandom(&v, sizeof(v));} // adds entropy to pool by hashing a high-resolution timestamp void SeedRandom(void); // returns a hexadecimal string representing the last seed hashed by SeedRandom() std::string GetLastSeedAsString(void); // returns a random base64 string of length , // uses '_' and '-' as the two non-alnum chars (see b64char() in Hash.hpp) std::string GetRandomString(size_t n); }}