1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Wait for entropy pool to fill and autosave in TestRNG example

This commit is contained in:
Rhys Weatherley 2015-04-02 06:37:52 +10:00
parent 152d24fba7
commit 7432d83676

View File

@ -21,6 +21,7 @@ TransistorNoiseSource noise(A1);
bool calibrating = false;
byte data[32];
unsigned long startTime;
size_t length = 48; // First block should wait for the pool to fill up.
void setup() {
Serial.begin(9600);
@ -65,8 +66,10 @@ void loop() {
RNG.loop();
// Generate output whenever 32 bytes of entropy have been accumulated.
if (RNG.available(sizeof(data))) {
// The first time through, we wait for 48 bytes for a full entropy pool.
if (RNG.available(length)) {
RNG.rand(data, sizeof(data));
printHex(data, sizeof(data));
length = 32;
}
}