I want to implement the coin flip mechanism in which the result will be independent of anything just like real coin flip.I am confused on how to make totally independent...

  • 3
    A coin flip is not "independent of anything". A coin flip's results depends on a discrete factors (where on the coin you strike, amount of force, angle of your finger when you strike, stiffness of your fingernail, movement of the hand-coin system, "thickness" and movement of air, height of landing surface, and nature of landing surface). If you control those factors, you can produce the same result every time. The same thing with computer PRNGs. – Adi Feb 3 '17 at 13:09

Depending on what language you are using, some of them can generate cryptographically secure pseudo-random integers, which is probably good enough for a coin flip mechanism, such as PHP 7's random_int function.

However, there are also true random number generation services out there, such as api.random.org. The randomness comes from atmospheric noise, rather than a pseudo-random algorithm.


You can't. That's why methods for what you really want are called CSPRNGs - Cryptographically Secure Pseudo Random Number Generators.

Yet, what is true for most of crypto is true here, too: If you don't know what you're talking about, try not to implement it yourself. Instead, use established libraries that offer what you need.


Of course you can. The coin is still dependent on it's physical state and velocity, but it is not discretely predictable.

https://www.random.org/coins/ has a random number generator based on atmospheric noise. That's a lot more random than a dice or a coin. it's quantum.

If you don't want an online service you can buy a hardware TRNG USB dongle or get the noise from a cheap RTL-SDR.

But the difference are mostly theoretical. For what you want, a CSPRNG will suffice. /dev/urandom will do on unix (and no, it's not inferor to /dev/random).

Not the answer you're looking for? Browse other questions tagged or ask your own question.