|
|
How do I use a random number generator? |
| Moderator: weidai (inherited from parent) | |
If you're running on a Win32 OS, or a Unix OS with /dev/random, then you can use AutoSeededRandomPool:#include "osrng.h" using namespace CryptoPP; . . . AutoSeededRandomPool rng; byte randomBytes[10]; rng.GenerateBlock(randomBytes, 10);Otherwise you should use RandomPool and seed it yourself with random, unpredictable data: RandomPool rng; rng.Put(seed, seedLen); byte randomBytes[10]; rng.GenerateBlock(randomBytes, 10); 2002-Dec-30 1:57pm weidai | |
| [Append to This Answer] | |
| 2002-Dec-30 1:57pm |
| Previous: |
|
| Next: |
|
| ||||||||||