Answer the question
In order to leave comments, you need to log in
How to make an honest number choice?
The task is to honestly choose the winning number WIN_NUMBER from 1 to TOTAL prematurely without knowing TOTAL.
Now I first choose any small RAND number from 0 to 1 ( RAND = Math.random() ) and show people the hash of it md5(RAND) and at the end, when I know the total number of TOTAL, I calculate the winning number in this way
WIN_NUMBER = floor((TOTAL - 0.0000000001) * (RAND / 100)) + 1
Answer the question
In order to leave comments, you need to log in
You can also guess a large integer INTRND (which does not allow you to select it by exhaustive search by hash, for example, 128 bits), publish its hash in the same way, and then WIN_NUMBER = (INTRND mod TOTAL) +1. But modular arithmetic is less accepted by users, so multiplication by the number [0..1] is more intuitive for everyone.
And salt, as rightly noted, be sure to keep it secret until disclosed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question