Random numbers are essential for all kinds of things, especially cryptography. Computers, however, can only produce pseudorandom numbers, which can be "guessed" by using sophisticated software. Truly random numbers are hard to come by. Luckily, with a few wires and a Ras Pi, one can create a lot of random numbers very quickly.

For this project you will need:
1x Raspberry Pi
3x Breadboard wires

And, for the optional LED output section:
1x LED
1x current-limiting resistor (for the LED)
3x Breadboard wires

Step 1: Wiring

This is the easiest wiring project you've ever done.
For the RNG inputs, connect breadboard wires to GPIO 4, 17, and 22. If that's all you want, you're done. skip to the coding.
For the LED output, connect a resistor and an LED in series (with the resistor on the positive pin of the LED), then connect the Pi's ground to the ground rail on the breadboard. Connect the other end of the LED to ground and the other end of the resistor to GPIO 25.
Very interesting. Thanks for your instruction.
How well does this RNG fare against the FIPS tests included in rngtest? It should pass most of them if you wish to consider it for crypto usage. If it's genuinely really fast, run it against the dieharder suite.<br> <br> Reading floating inputs is strongly influenced by how clean your power supply is, and what other RF noise in the neighbourhood. I'd be very surprised if these weren't just sampling 50 Hz/60 Hz ripple. Even the Arduino folks &mdash; who have built-in AtoD converters on their boards, unlike the Raspberry Pi's digital inputs &mdash; no longer recommend reading a floating input as a random seed for anything other than toy applications.<br> <br> Your circuit is easily tampered with (join or ground the wires; you'll get a sweet stream of zeroes) and your code has no way of detecting if the input values are biased and stopping the output. Producing a good source of random bits is <em>hard</em>; even IBM got it wrong for years with <a href="https://en.wikipedia.org/wiki/RANDU" rel="nofollow">RANDU</a>, and Intel had to jump through hoops to make <a href="http://spectrum.ieee.org/computing/hardware/behind-intels-new-randomnumber-generator" rel="nofollow">RdRand</a> useful.<br> <br> So, while this is a good first effort, the real work comes in verifying and hardening the system. You might find out that the Raspberry Pi's RNG built into the SOC is not so bad after all &hellip;
If you want a hardware RNG, The RPi has one already, no wiring required:<br> <br> <a href="http://scruss.com/blog/2013/06/07/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator/" rel="nofollow">http://scruss.com/blog/2013/06/07/well-that-was-unexpected-the-raspberry-pis-hardware-random-number-generator/</a>
Yeah, but it's reeeeeeeeeally slow. Just try seeding 300 keys from /dev/random, it took me twenty minutes!
It sounds like you're trying to rely on the &quot;random&quot; noise present on the ground line to generate what you call &quot;truly random&quot; numbers. Is that true? If so, you should be aware that the randomness of those numbers is strongly coupled to how well filtered your power supply is.
The breadboard wires act as small antennas which, on 3v3, modulate enough to give differing high/low readings based on signal, which is mostly atmospheric noise. You can see this by simply unplugging the breadboard from the Pi and running the program - you'll get almost exclusively 0s.

About This Instructable




More by I Ate The Pi:Raspberry Pi Colored Server Case Mod A Raspberry Pi-based Truly Random Number Generator How to Add an On Switch to the Raspberry Pi Model B Rev 2 
Add instructable to: