/////////////////////////
//
// Password Vault
// by Les Hall
// created Thu Apr 6 2017
//
//
// include libraries
#include <Adafruit_CircuitPlayground.h>
#include <Wire.h>
#include <SPI.h>
#include <Keyboard.h>
// global variables
unsigned int value = 0; // numeric encoding of selected bits
int bright = 20; // how bright the pixels are , 1 to 255
int pins[] = {0, 1, 2, 3, 6, 9, 10, 12}; // Circuit Playground pins
int led[] = {3, 4, 1, 0, 6, 8, 9, 5}; // LEDs assigned to pins
bool leftButtonPressed = false; // status of left button
bool rightButtonPressed = false; // status of right button
void setup() {
// allow Circuit Playground to act as USB HID device
Keyboard.begin();
// start the Circuit Playground features
CircuitPlayground.begin();
}
void loop() {
// read in the capacitor sense values
// and set the value accordingly
do {
// loop thru the bits
for (int i = 0; i < 8; ++i) {
// set b to the cap sense bit value
int b = bitRead(value, i);
if (CircuitPlayground.readCap(pins[i]) > 25)
b = !b;
bitWrite(value, i, b); // write each bit accordingly
// display each LED as purple (b = 0) or aqua (b = 1)
CircuitPlayground.setPixelColor(led[i],
bright*(1-b), bright*b, bright);
}
// check for either button pressed
leftButtonPressed = CircuitPlayground.leftButton();
rightButtonPressed = CircuitPlayground.rightButton();
delay(250);
} while ( !(leftButtonPressed || rightButtonPressed) ); // exit if pressed
delay(500);
// apply the unique personal seed mask
if (leftButtonPressed) {
// set the seed value
randomSeed(value);
} else if (rightButtonPressed) {
// print out a password
int numChars = int(random(12, 16));
for (int i = 0; i < numChars; ++i) { // loop thru the length
float percentage = random(100);
if (percentage > 67)
Keyboard.println( char( random(int('a'), int('z')+1) ) );
else if (percentage < 33)
Keyboard.println( char( random(int('A'), int('Z')+1) ) );
else
Keyboard.println( char( random(int('0'), int('9')+1) ) );
}
// set up for next time
CircuitPlayground.playTone(500, 100); // sound a beep
}
// reset for next password
CircuitPlayground.clearPixels(); // turn LEDs off
delay(1000);
}
LesHall wrote:It takes a level headed person to react calmly when a hot-head like me spews junk.
Good point. This attack is only really practical in offline-attack scenarios (like a local computer login or hard-drive encryption), or if the hash database gets stolen.adafruit_support_mike wrote:if a security system allows 39k failures without saying, "uh, dude?", the size of the keyspace is the least of your problems. ;-)