Skip to content

Instantly share code, notes, and snippets.

Walter Anderson wandrson

View GitHub Profile
wandrson / TrueRandomSeed.ino
Last active Sep 12, 2018
This is a simple straightforward and relatively lightweight example of how to seed the internal PRNG function with a truly random value
View TrueRandomSeed.ino
// TrueRandomSeed.ino
// This example sketch shows how to provide a truly random seed value to the built in
// library pseudo random number generator. This ensures that your sketch will be
// using a different sequence of random numbers every time it runs. Unlike the
// usually suggested randomSeed(analogRead(0)) this method will provide a much more
// uniform and varied seed value. For more information about the basic technique used
// here to produce a random number or if you need more than one such number you can
// find a library, Entropy from the following web site along with documentation of how
// the library has been tested to provide TRUE random numbers on a variety of AVR
// chips and arduino environments.
wandrson /
Last active May 20, 2017
Simple python script to display raspberry pi ip address using a Pimoroni Blinkt
#!/usr/bin/env python
import socket
from time import sleep
from blinkt import set_clear_on_exit, set_pixel, show
colors = [
[ 0, 0, 0],#0 black
[ 32, 32, 0],#1 brown
[255, 0, 0],#2 red
wandrson / DiceAnalysis.R
Created Apr 6, 2014
R script to analyze random data simulating a six sided die
View DiceAnalysis.R
# Analyze dice data to establish if it is random
sink("analysis.prn") <- read.csv("dice.txt")$Sum <-$Die1 +$Die2
png(filename="cumulative.png", width=800, height=600)
wandrson / due_hwrng_speed_test.ino
Created Apr 5, 2014
A short Arduino Due sketch that measures the time it takes the Due's ARM processor's true random number generator to produce 1Mb of entropy.
View due_hwrng_speed_test.ino
// due_hwrng_speed_test.ino
// by Walter Anderson
// April 5, 2014
// This is a speed test run on an Arduino Due with an ATSAM3X8E-AU chip dated 1317, it produced the following
// output:
// Starting time test for speed of generation of hardware randrom number gebnrator.
// It took 262 milliseconds to generato 1,048,576 bytes of entropy!
// This equates to 4,002,198 bytes per second!
wandrson / due_hwrng_test.ino
Created Apr 5, 2014
A short Arduino Due sketch that streams 32-bit random numbers using the TRNG component on the ARM processor. Developed to test the validity of the entropy produced as part of updating my Arduino Entropy library to make use of this source, if used on a Due chip.
View due_hwrng_test.ino
// DUE's TRNG 32 bits every 84 ticks
#include <sam.h>
#include <sam3xa/include/component/component_trng.h>
uint32_t test_hwrng()
static bool enabled = false;
if (!enabled) {
wandrson /
Last active Aug 29, 2015
This python program will convert up to a specified maximum number of 32-bit numbers to a binary file.
#! /usr/bin/python
import sys
import struct
infilename = sys.argv[1]
outfilename = sys.argv[2]
maxsize = int(sys.argv[3])
wandrson /
Created Mar 27, 2014
Python scrupt that performs basic tests (derived from ent utility) on a binary file and also produces both a histogram of the distribution of bytes as well as a scatter plot of those byte pairs. Useful for preliminary testing of quality of entropy (random) data sources.
#! /usr/bin/python
# This program will take a file name from the command line and analyze its entropy, using many of the same algorithms
# as the ent program from hotbits
import sys
import struct
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
wandrson / RandomCardDraw.pde
Last active Aug 29, 2015
The following example demonstrates how to produce the numbers 1 to X in a random order, where each number only appears once, and that all numbers are produced.
View RandomCardDraw.pde
// FILE: RandomCardDraw.ino
// AUTHOR: Rob Tillaart and Walter Anderson
// VERSION: 1.0.0
// PURPOSE: generate random sequence (optimized)
// DATE: April 24, 2014
// URL:
// The Entropy library provides true random numbers and can be obtained from:
#include <Entropy.h>
You can’t perform that action at this time.