Skip to content

Commit

Permalink
Prefer a lightweight random generator
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Feb 23, 2024
1 parent 20ffc45 commit f71fa70
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/passwordManager/passwordManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const string DefaultPasswordFile = getHomeDir() + "/.privacyShield/passwords";
/// \param rhs another record to be compared with lhs.
/// \return true if lhs is less than (i.e. is ordered before) rhs, else false.
bool constexpr comparator
// Avoid a gcc compiler error on ignored scoped attribute directives (-Werror=attributes is enabled in debug config),
// Avoid a compiler error on ignored scoped attribute directives (-Werror=attributes is enabled in debug config),
// while still encouraging both Clang and GCC compilers to inline the function.
#if __clang__ // __clang__ is checked first since Clang might also define __GNUC__, but GCC never defines __clang__.
#if __clang__
[[clang::always_inline]]
#elif __GNUC__
[[gnu::always_inline]]
Expand Down Expand Up @@ -765,9 +765,8 @@ void passwordManager() {
{8, importPasswords},
{9, exportPasswords}
};

std::random_device rd; // get a random number from hardware
std::mt19937 gen(rd()); // seed the generator
// A fast, lightweight random number generator
std::minstd_rand gen(std::random_device{}()); // seed the generator
std::uniform_int_distribution<int> dist(0, 6); // define the range

while (true) {
Expand Down

0 comments on commit f71fa70

Please sign in to comment.