QCA::Random

Search for usage in LXR

#include <QtCrypto>

Inheritance diagram for QCA::Random:

Public Member Functions

 Random (const QString &provider=QString())
 
 Random (const Random &from)
 
uchar nextByte ()
 
SecureArray nextBytes (int size)
 
Randomoperator= (const Random &from)
 
- Public Member Functions inherited from QCA::Algorithm
 Algorithm (const Algorithm &from)
 
void change (const QString &type, const QString &provider)
 
void change (Provider::Context *c)
 
Provider::Contextcontext ()
 
const Provider::Contextcontext () const
 
Algorithmoperator= (const Algorithm &from)
 
Providerprovider () const
 
Provider::ContexttakeContext ()
 
QString type () const
 

Static Public Member Functions

static SecureArray randomArray (int size)
 
static uchar randomChar ()
 
static int randomInt ()
 

Additional Inherited Members

- Protected Member Functions inherited from QCA::Algorithm
 Algorithm ()
 
 Algorithm (const QString &type, const QString &provider)
 

Detailed Description

Source of random numbers.

QCA provides a built in source of random numbers, which can be accessed through this class. You can also use an alternative random number source, by implementing another provider.

The normal use of this class is expected to be through the static members - randomChar(), randomInt() and randomArray().

Examples
randomtest.cpp.

Definition at line 65 of file qca_basic.h.

Constructor & Destructor Documentation

◆ Random() [1/2]

QCA::Random::Random ( const QString & provider = QString())

Standard Constructor.

Parameters
providerthe name of the provider library for the random number generation

◆ Random() [2/2]

QCA::Random::Random ( const Random & from)

Copy constructor.

Parameters
fromthe Random object to copy from

Member Function Documentation

◆ nextByte()

uchar QCA::Random::nextByte ( )

Provide a random byte.

This method isn't normally required - you should use the static randomChar() method instead.

See also
randomChar
Examples
randomtest.cpp.

◆ nextBytes()

SecureArray QCA::Random::nextBytes ( int size)

Provide a specified number of random bytes.

This method isn't normally required - you should use the static randomArray() method instead.

Parameters
sizethe number of bytes to provide
See also
randomArray
Examples
randomtest.cpp.

◆ operator=()

Random & QCA::Random::operator= ( const Random & from)

Assignment operator.

Parameters
fromthe Random object to copy state from

◆ randomArray()

static SecureArray QCA::Random::randomArray ( int size)
static

Provide a specified number of random bytes.

// build a 30 byte secure array.
static SecureArray randomArray(int size)
Provide a specified number of random bytes.
Secure array of bytes.
Definition qca_tools.h:317
Parameters
sizethe number of bytes to provide
Examples
randomtest.cpp.

◆ randomChar()

static uchar QCA::Random::randomChar ( )
static

Provide a random character (byte)

This is the normal way of obtaining a single random char (i.e. 8 bit byte), as shown below:

myRandomChar = QCA::Random::randomChar();
static uchar randomChar()
Provide a random character (byte)

If you need a number of bytes, perhaps randomArray() may be of use.

Examples
randomtest.cpp.

◆ randomInt()

static int QCA::Random::randomInt ( )
static

Provide a random integer.

This is the normal way of obtaining a single random integer, as shown below:

myRandomInt = QCA::Random::randomInt();
static int randomInt()
Provide a random integer.
Examples
randomtest.cpp.

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:46:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.