I am writing a random text generator in C++ which uses an LCG to produce random numbers, then does a base conversion (with the digits of the new base represented as letters and punctuation) to create text from the random integers. I have found that the results of the LCG are not quite random enough. For example, if I follow any particular letter, like the fifth or 500th on the page, it will follow an easily observable pattern like a-x-b-y-c-z as I move through sequential inputs.
I thought I might be able to mask this by breaking the numbers which result from the LCG into chunks and applying some bit shifting operations to them. The integers which result from my LCG are about 5000 digits and the strings 3200 characters, and I am not sure what the most efficient way to break either into 32-bit (for example) chunks would be.
If I can break the number or string into chunks of bits, I planned to apply the bit-shifting operations from a mersenne twister to them, since they are easily reversible, which is important to my project.
My question is what the best way to break a large integer or string like that into uniform chunks of bits is. Or, whether there is a more efficient method which could produce the same results (making output appear more random while remaining reversible).
Thank you for your help.
Aucun commentaire:
Enregistrer un commentaire