source: psi/trunk/cutestuff/util/qrandom.cpp@ 63

Last change on this file since 63 was 2, checked in by dmik, 19 years ago

Imported original Psi 0.10 sources from Affinix

File size: 351 bytes
Line 
1#include"qrandom.h"
2
3#include<stdlib.h>
4
5uchar QRandom::randomChar()
6{
7 return rand();
8}
9
10uint QRandom::randomInt()
11{
12 QByteArray a = randomArray(sizeof(uint));
13 uint x;
14 memcpy(&x, a.data(), a.size());
15 return x;
16}
17
18QByteArray QRandom::randomArray(uint size)
19{
20 QByteArray a(size);
21 for(uint n = 0; n < size; ++n)
22 a[n] = randomChar();
23 return a;
24}
Note: See TracBrowser for help on using the repository browser.