Lua: Fix type confusion between signed and unsigned
[lsnes.git] / include / core / random.hpp
blob81ed7f89a4edade3ea6111ccfc63c5625f60b09b
1 #ifndef _random__hpp__included__
2 #define _random__hpp__included__
4 #include <string>
5 #include <vector>
6 #include <stdexcept>
7 #include "library/string.hpp"
9 /**
10 * \brief Get random hexes
12 * Get string of random hex characters of specified length.
14 * \param length The number of hex characters to return.
15 * \return The random hexadecimal string.
16 * \throws std::bad_alloc Not enough memory.
18 std::string get_random_hexstring(size_t length) throw(std::bad_alloc);
20 /**
21 * \brief Set random seed
23 * This function sets the random seed to use.
25 * \param seed The value to use as seed.
26 * \throw std::bad_alloc Not enough memory.
28 void set_random_seed(const std::string& seed) throw(std::bad_alloc);
30 /**
31 * \brief Set random seed to (hopefully) unique value
33 * This function sets the random seed to value that should only be used once. Note, the value is not necressarily
34 * crypto-secure, even if it is unique.
36 * \throw std::bad_alloc Not enough memory.
38 void set_random_seed() throw(std::bad_alloc);
40 /**
41 * Mix some entropy.
43 void random_mix_timing_entropy();
45 /**
46 * 256 bits of as high quality entropy as possible.
48 void highrandom_256(uint8_t* buf);
50 /**
51 * Contribute buffer of entropy.
53 void contribute_random_entropy(void* buf, size_t bytes);
55 #endif