diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2018-01-02 13:04:29 +0100 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2018-01-02 13:04:29 +0100 |
commit | f14282412b8a82888b71a3268c985709ba9364d3 (patch) | |
tree | 690dffe3438c25b9dd75254db7c6a8b43a7b0907 /src/util.cpp | |
parent | 722e36e1541e9fdf46284e4915e4a77e1088e1d3 (diff) |
Generate Password code from #338 placed
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/src/util.cpp b/src/util.cpp index cf334122..ae65b519 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -177,31 +177,3 @@ void Util::copyDir(const QString src, const QString dest) { dest + QDir::separator() + file); } } - -/* Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. */ - -#include <QRandomGenerator> -#include <QString> - -quint32 boundedRandom(quint32 bound) { - if (bound < 2) - return 0; - - quint32 randval; - const quint32 max_mod_bound = (1 + ~bound) % bound; - - do - randval = QRandomGenerator::system()->generate(); - while (randval < max_mod_bound); - - return randval % bound; -} - -static QString generateRandomPassword(const QString &charset, - unsigned int length) { - QString out; - for (unsigned int i = 0; i < length; ++i) - out.append(charset.at(static_cast<int>( - boundedRandom(static_cast<unsigned int>(charset.length()))))); - return out; -} |