Instantly share code, notes, and snippets.

# Walter Andersonwandrson

• Sort options
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.
View analyze.py
 #! /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
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: // http://code.google.com/p/avr-hardware-random-number-generation/wiki/WikiAVRentropy #include
Last active Aug 29, 2015
This python program will convert up to a specified maximum number of 32-bit numbers to a binary file.
View long2bin.py
 #! /usr/bin/python import sys import struct try: infilename = sys.argv outfilename = sys.argv maxsize = int(sys.argv) except:
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! //
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 #include uint32_t test_hwrng() { static bool enabled = false; if (!enabled) { pmc_enable_periph_clk(ID_TRNG); TRNG->TRNG_IDR = 0xFFFFFFFF;
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 setwd("~/Development/hardware-rng/avr-hardware-random-number-generation/Entropy/examples/Dice") library(foreign) library(prettyR) sink("analysis.prn") Dice.data <- read.csv("dice.txt") Dice.data\$Sum <- Dice.data\$Die1 + Dice.data\$Die2 png(filename="cumulative.png", width=800, height=600) hist(Dice.data\$Sum, freq=FALSE,
Last active May 20, 2017
Simple python script to display raspberry pi ip address using a Pimoroni Blinkt
View display_ip.py
 #!/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
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.
You can’t perform that action at this time.