3 ms·
Language lawyer note: std::random_device isn't guaranteed to be hardware-based, or anything in particular: http://en.cppreference.com/w/cpp/numeric/random/rand
by jacobparker 12y ago
Language lawyer note: std::random_device isn't guaranteed to be hardware-based, or anything in particular:
http://en.cppreference.com/w/cpp/numeric/random/random_device http://en.cppreference.com/w/cpp/numeric/random/random_devic...
(GNU libstdc++ will use rdrand if possible, otherwise it will read from /dev/urandom: https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=libstdc%2B%2B-v3/src/c%2B%2B11/random.cc;hb=HEAD https://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=libstdc%2B...)
- sjolsen 12y agoYou are correct; and of course, any hardware-level behaviour is likely to be implementation defined. I should note that MSVC [1] guarantees "non-deterministic and cryptographically secure" behaviour; and that libc++ [2] uses the "cryptographically secure" rand_s [3] on Windows, NaCl on other platforms where NaCl is available, and /dev/urandom where it isn't. [1] http://msdn.microsoft.com/en-us/library/bb982250.aspx http://msdn.microsoft.com/en-us/library/bb982250.aspx [2] https://github.com/llvm-mirror/libcxx/blob/master/src/random.cpp https://github.com/llvm-mirror/libcxx/blob/master/src/random... [3] http://msdn.microsoft.com/en-us/library/sxtz2fa8.aspx http://msdn.microsoft.com/en-us/library/sxtz2fa8.aspx