mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Replace std::random_shuffle with std::shuffle
According to [1], std::random_shuffle is deprecated in C++14 and removed in C++17. Since std::shuffle is available since C++11 as a replacement and monero already requires C++11, this is a good replacement. A cryptographically secure random number generator is used in all cases to prevent people from perhaps copying an insecure std::shuffle call over to a place where a secure one would be warranted. A form of defense-in-depth. [1]: https://en.cppreference.com/w/cpp/algorithm/random_shuffle
This commit is contained in:
parent
1bb4ae3b5e
commit
7b9a420787
5 changed files with 7 additions and 7 deletions
|
@ -143,7 +143,7 @@ TEST(rolling_median, order)
|
|||
m.insert(random[i]);
|
||||
ASSERT_EQ(med, m.median());
|
||||
|
||||
std::shuffle(random.begin(), random.end(), std::default_random_engine(crypto::rand<unsigned>()));
|
||||
std::shuffle(random.begin(), random.end(), crypto::random_device{});
|
||||
m.clear();
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
m.insert(random[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue