The code below shows the normal way to use the QCA::Random class.
The code below shows the normal way to use the QCA::Random class.
#include <QtCrypto>
#include <QCoreApplication>
#include <QDebug>
#include <iostream>
#ifdef QT_STATICPLUGIN
#include "import_plugins.h"
#endif
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
qDebug() << "This example generates random numbers";
int randInt;
qDebug() << "A random number: " << randInt;
unsigned char randChar;
std::cout << "A random character: " << randChar << std::endl;
std::cout << "A random 10 byte array (in hex): ";
std::cout << qPrintable(
QCA::Hex().arrayToString(tenBytes)) << std::endl;
return 0;
}
Hexadecimal encoding / decoding.
Definition qca_textfilter.h:165
Convenience method for initialising and cleaning up QCA.
Definition qca_core.h:660
Source of random numbers.
Definition qca_basic.h:66
uchar nextByte()
Provide a random byte.
static SecureArray randomArray(int size)
static uchar randomChar()
SecureArray nextBytes(int size)
Provide a specified number of random bytes.
Secure array of bytes.
Definition qca_tools.h:317