Hi,
I would like to create a random packet of data, 128 bits long (16bytes).
My basic idea is to generate 16 pseudo-random numbers (between 0 and 255), then turn each of these numbers into their equivalent bytes. Then I intend to put these 16 bytes end to end to create my packet.
This is what I have so far:
Qt Code:
void Loader::calculateRandomCode() { int n; n = qrand() % 255; // limits the random number to between 0 and 255 label->show(); // prints to screen just so I can see whats going on }To copy to clipboard, switch view to plain text mode
How do I turn n into a byte?
Thanks for reading
Bookmarks