squawk/qomemo/sce.cpp

27 lines
612 B
C++
Raw Normal View History

/*
* Created by victoria on 2021-05-12.
*/
#include "sce.h"
#include <QRandomGenerator>
2021-05-13 14:54:37 +00:00
#define RPAD_ALPHABET "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
constexpr int RPAD_MAX_LENGTH = 200;
QString QXmpp::Sce::generatePadding() {
2021-05-13 14:54:37 +00:00
QRandomGenerator random{};
QString result{};
QString alphabet{QStringLiteral(RPAD_ALPHABET)};
2021-05-13 14:54:37 +00:00
auto length = random.bounded(RPAD_MAX_LENGTH);
result.resize(length);
2021-05-13 14:54:37 +00:00
for (auto i = 0; i < length; ++i) {
result[i] = alphabet[random.bounded(alphabet.length())];
}
2021-05-13 14:54:37 +00:00
return result;
}