Giter VIP home page Giter VIP logo

esprandom's Introduction

MIT Licence

ESPRandom

Generate random numbers and UUIDs on the ESP8266 and ESP32 using the hardware RNG. Due to changes in requirements, I have moved to a different approach which has been implemented in the following library: ESP UUID. It supports ArduinoJson and std::map. Pull requests will be accepted here, but no active contribution from my side will be made.

Examples

Get a Guaranteed Random Number

#include "Arduino.h"
#include "ESPRandom.h"

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(ESPRandom::get());
  delay(1000);
}

Get a Very Unique UUID

#include "Arduino.h"
#include "ESPRandom.h"

void setup() {
  Serial.begin(115200);
}

void loop() {
  uint8_t uuid[16];
  ESPRandom::uuid(uuid);
  Serial.println(ESPRandom::uuidToString(uuid));
  delay(1000);
}

Sunny Conditions for Random Numbers

For random numbers to be generated, the radio (WiFi or Bluetooth) have to be active. Therefore, when getting a random number (or UUID) it will check if WiFi is active and activate it (in station mode) if this is not the case.

Another reason for creating this library is that the alternatives are covered in copy-left licences which significantly restrict their use.

Randomness Test

Test Name Rewinds tsamples psamples p-value Assessment
diehard_birthdays 1 100 100 0.08369138 PASSED
diehard_operm5 8 1000000 100 0.14173840 PASSED
diehard_rank_32x32 18 40000 100 0.00000000 FAILED
diehard_rank_6x8 22 100000 100 0.95923936 PASSED
diehard_bitstream 24 2097152 100 0.19399156 PASSED
diehard_opso 40 2097152 100 0.00055960 WEAK
diehard_oqso 50 2097152 100 0.55745812 PASSED
diehard_dna 55 2097152 100 0.08215937 PASSED

Attribution

Derived the UUID v1 generation algorithm from the stduuid library.

esprandom's People

Contributors

moritz89 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.