Nikhil, the term RNG is actually a misnormer the numbers that a RNG generates are actually pseudo random numbers, meaning they are reproducible and the generating function is known(hence they can be reproduced). Most of the RNG's we know of are LCG's(Linear Congruential Generators) They work on a simple recurrence relation r(i+1) = (A * r(i) ) MOD m MOD is the modulus operator. In ur case Considering that r(i), A and m are constant r(i+1) will also be the same each time u execute the program. A clever workaround will be calling srand() with the seed as the current system time. The ideal generators are those that have a period equal to 'm'. The period is the longest possible non-overlapping sequence of numbers generated by a LCG. the greater the period the more desirable is the generator(but the sequence of numbers generated is also important). The 'seed' is nothing but r(0) ie the first r on the RHS of the recurrence relation. The C library RNG is not that good in the sense that it has failed many theoretical and empirical tests. there are a lot of RNG'S that are much better than this generator and have whopping periods.They also provide the user with the ability to generate disjoint substreams of numbers using the same generator. Random number generation is a tricky process and needs a lot of mathematical intuition. And finally if you are looking for truly random numbers try weather data from internet weather stations.These are truly random. For a more thorough understanding read Knuth:Art of computer programming. Enjoy!! Sankha
Sankha,
If I needed to use a PRNG for AES key (128 bits) and i called rand() 4 times, I still have a entropy of only 32 bits instead of 128 bits.
which means i just weakened the algorithm!
what do I do?
-Shailesh
--- Sankha Subhra Som sankha@atc.tcs.co.in wrote:
Nikhil, the term RNG is actually a misnormer the numbers that a RNG generates are actually pseudo random numbers, meaning they are reproducible and the generating function is known(hence they can be reproduced). Most of the RNG's we know of are LCG's(Linear Congruential Generators) They work on a simple recurrence relation r(i+1) = (A * r(i) ) MOD m MOD is the modulus operator. In ur case Considering that r(i), A and m are constant r(i+1) will also be the same each time u execute the program. A clever workaround will be calling srand() with the seed as the current system time. The ideal generators are those that have a period equal to 'm'. The period is the longest possible non-overlapping sequence of numbers generated by a LCG. the greater the period the more desirable is the generator(but the sequence of numbers generated is also important). The 'seed' is nothing but r(0) ie the first r on the RHS of the recurrence relation. The C library RNG is not that good in the sense that it has failed many theoretical and empirical tests. there are a lot of RNG'S that are much better than this generator and have whopping periods.They also provide the user with the ability to generate disjoint substreams of numbers using the same generator. Random number generation is a tricky process and needs a lot of mathematical intuition. And finally if you are looking for truly random numbers try weather data from internet weather stations.These are truly random. For a more thorough understanding read Knuth:Art of computer programming. Enjoy!! Sankha -- SANKHA SUBHRA SOM ATC - BIOINFORMATICS TCS KLK BUILDING. HYDERABAD-1 Ph:(040)6787980-1024
An anonymous digitoid
The world is populated in the main by people who should not exist.
__________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com