summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/libiris/cutestuff/util/qrandom.cpp
blob: ed1d1a62be8653191212575c2845dfd463438cbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "qrandom.h"

#include <stdlib.h>

uchar QRandom::randomChar()
{
	return rand();
}

uint QRandom::randomInt()
{
	TQByteArray a = randomArray(sizeof(uint));
	uint x;
	memcpy(&x, a.data(), a.size());
	return x;
}

TQByteArray QRandom::randomArray(uint size)
{
	TQByteArray a(size);
	for(uint n = 0; n < size; ++n)
		a[n] = randomChar();
	return a;
}