1

In c++, would using the std::chrono::high_resolution_clock to time any function call repeatedly be a good source of entropy?

Test Email
  • 11
  • 2
  • `std::random_device` is what's commonly used. Example: `std::mt19937 prng(std::random_device{}());` – Ted Lyngmo Mar 01 '21 at 12:21
  • RDRAND instruction, arrival times of network packets or keyboard characters, audio noise from mic. Someone made a RNG from a lava lamp. – stark Mar 01 '21 at 12:26
  • See https://www.pcg-random.org/posts/simple-portable-cpp-seed-entropy.html – L. Scott Johnson Mar 01 '21 at 12:36
  • 1
    Any clock is not a good cryptographically secure seed. You need as wide a range of entropy sources as you can manage, including a clock, but also including as many other sources as available. A good place to start might be the cryptographically secure PRNG provided by your operating system, since that will have access to various under-the-hood sources not available to normal programs. – rossum Mar 01 '21 at 20:13
  • /dev/urandom that is the key. https://stackoverflow.com/q/35726331/1820553 – kelalaka Mar 01 '21 at 22:38

0 Answers0