I have learned new crypto words, so I rewrote the question:
I have quite random 32-byte hash andwhich I am tryingwant to finduse as a good method, how to extractseed for generation of 10 randompseudo-random positive numbers from that hash up to some maximum number and, the extractiongeneration must be reproducible for everyone. I would prefer, if those 10 numbers would differ from each other.
I can't explain it well (so you can edit the description), but thereThere is an example:
hash=Pkq5skE7tp=j#{y"+R$6~mg!z"4g/Utwand I need to reproducibly generate count=10 randompseudo-random positive numbers up to say max=500.
So approaches that came to my mind:
- I can take first 8 bytes
Pkq5skE7and cast them to 64-bit integer, then use modulo500on the result and have first number, then take other 8 bytes starting 1 byte rightkq5skE7t, cast it, modulo it and get second number and I can get all 10 number like that.
Would those numbers seem pretty random or would they have some pattern?
There is not preferable effect of having 2 numbers the same. - I can take first 8 bytes
Pkq5skE7and cast them to 64-bit integer, then use modulo500on the result and have first number, then calculate other numbers with adding500/10=50to the result. So if the result of the cast would be 475, then other numbers would be 25, 75, .., 425.
I know that there is randomness only for the first number, but that would be good enough if method 1) would have some inconvinient pattern problem (like numbers distributed close to each other or something).
Compared to 1), numbers would be unique and that is an advantage. - If methods 1) and 2) won't be very good, I can again cast some bytes to 64-bit integer, do modulo, get number and take 9 following numbers from following positions.
But that loses the random-like factor and I would prefer if the 10 numbers' would seem random and not much related to each other, the same problem can be said for 2), but it's preferable to have the numbers distributed over the whole spectrum. - Some other approach?
Basically I prefer 1), but maybe there is something better that can't yield the same number twice, maybe numbers from 1) can have a lot in common, because it's just shifting 1 byte right, I don't know.
I can tell it's used for something like drawing in a lottery, but the hash is known and the lottery numbers must be reproducible from that hash. It is preferable that the numbers don't have relationship between each other, but I am not sure, if it's possible and maybe it's ok for those numbers to just look like randompseudo-random and only the first being randompseudo-random and other having not-obvious relationship to it.
Suggestions?