More comments, cleanups and added LICENSE and README.
This commit is contained in:
parent
96d4a99aec
commit
8c4c00ae0a
5 changed files with 72 additions and 26 deletions
|
|
@ -1,45 +1,63 @@
|
||||||
|
// Passkey for Arduino using the Digispark Rev.3 board.
|
||||||
|
// Copyright 2022 by Johannes Findeisen <you@hanez.org>
|
||||||
|
// Licensed under the terms of the MIT license.
|
||||||
|
|
||||||
|
// For using the Blinker library you have to install it from:
|
||||||
|
// https://github.com/MajenkoLibraries/Blinker
|
||||||
|
// Since the code is included in Passkey you easily can just copy
|
||||||
|
// Blinker/src/Blinker.cpp and Blinker/src/Blinker.h to the root of
|
||||||
|
// Passkey.
|
||||||
#include "Blinker.h"
|
#include "Blinker.h"
|
||||||
#include "DigiKeyboard.h"
|
#include "DigiKeyboard.h"
|
||||||
|
|
||||||
// the button pin
|
// The button pin
|
||||||
#define BUTTON_PIN 0
|
#define BUTTON_PIN 0
|
||||||
// the LED pin
|
// The LED pin
|
||||||
#define LED_PIN 1
|
#define LED_PIN 1
|
||||||
// the pause after last button press before executing a command
|
// The pause after last button press before executing a command
|
||||||
#define PAUSE 2000
|
#define PAUSE 2000
|
||||||
|
|
||||||
// local variables
|
// Local variables
|
||||||
unsigned long last;
|
unsigned long last;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
// create blinker
|
// Create blinker object
|
||||||
Blinker blinker(LED_PIN);
|
Blinker blinker(LED_PIN);
|
||||||
|
|
||||||
// the list of available passwords
|
// The list of available passwords
|
||||||
// the number and overall lenght of passwords depends because the memory of the digispark is very limited...
|
// The number and overall lenght of passwords depends
|
||||||
// i recommend to use a prefix you easily can remember for the password/passwords to make the passwords
|
// because the memory of the digispark is very limited...
|
||||||
// on the passkey unusable for others if you have lost your passkey. E.g.: WhatAWonderfulWorld -> then press the button.
|
// I recommend to use a prefix you easily can remember
|
||||||
|
// for the password/passwords to make the passwords
|
||||||
|
// on the passkey unusable for others in case you've lost
|
||||||
|
// your passkey. E.g.: WhatAWonderfulWorld -> then press the button.
|
||||||
const char *passwords[] = {
|
const char *passwords[] = {
|
||||||
"n0Emb871NAQPSIqBoldh8R7UDaNhncF7Pt60Amdo6GWdTdAPwVBi2A3KU8x8DTCRo6GWdTdXNn2wLh3SUbxVWQvFDVPtatDg", // passwords[0]
|
// passwords[0]
|
||||||
"oaxt6e3lSgflOuJ3C6Q6sUb5gvmvI5IEPFku5fqcbxJljBOUblHIT121wCu", // passwords[1]
|
"n0Emb871NAQPSIqBoldh8R7UDaNhncF7Pt60Amdo6GWdTdAPwVBi2A3KU8x8DTCRo6GWdTdXNn2wLh3SUbxVWQvFDVPtatDg",
|
||||||
"jUgKGBtiJ0iNN1Ok9vejrXNn2wLh3SUbxVWQvFDVPtat0OxJlKU8x8DTCRo6GWdTdAPwVBi2A3KUrTKQwjUgK", // passwords[2]
|
// passwords[1]
|
||||||
"G57dFnXsPUnRq1eC1CjrGxpCjuiJFlDti54W6wBS9Ro6GWdTdAPwVBi2A3KU8x8KGBtiJ0iNN1Ok9vejrXNn2wLhH" // etc...
|
"oaxt6e3lSgflOuJ3C6Q6sUb5gvmvI5IEPFku5fqcbxJljBOUblHIT121wCu",
|
||||||
|
// passwords[2]
|
||||||
|
"jUgKGBtiJ0iNN1Ok9vejrXNn2wLh3SUbxVWQvFDVPtat0OxJlKU8x8DTCRo6GWdTdAPwVBi2A3KUrTKQwjUgK",
|
||||||
|
// passwords[3]
|
||||||
|
"G57dFnXsPUnRq1eC1CjrGxpCjuiJFlDti54W6wBS9Ro6GWdTdAPwVBi2A3KU8x8KGBtiJ0iNN1Ok9vejrXNn2wLhH"
|
||||||
};
|
};
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// set button pin to high
|
// Set button pin to high.
|
||||||
pinMode(BUTTON_PIN, INPUT);
|
pinMode(BUTTON_PIN, INPUT);
|
||||||
|
// Set BUTTON_PIN pin to high because the button is connected
|
||||||
|
// to GND when pressed and will go LOW
|
||||||
digitalWrite(BUTTON_PIN, HIGH);
|
digitalWrite(BUTTON_PIN, HIGH);
|
||||||
|
|
||||||
// set blink effect (ON, OFF) in milliseconds
|
// Set blink effect (ON, OFF) in milliseconds
|
||||||
blinker.setDelay(25, 10000);
|
blinker.setDelay(25, 10000);
|
||||||
blinker.start();
|
blinker.start();
|
||||||
|
|
||||||
// initialize HID
|
// Initialize HID
|
||||||
DigiKeyboard.delay(0);
|
DigiKeyboard.delay(0);
|
||||||
DigiKeyboard.sendKeyStroke(0);
|
DigiKeyboard.sendKeyStroke(0);
|
||||||
|
|
||||||
// light up the LED for a second to show that passkey is ready
|
// Light up the LED for a second to show that passkey is ready
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
digitalWrite(LED_PIN, HIGH);
|
digitalWrite(LED_PIN, HIGH);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
@ -47,23 +65,23 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// start LED blink effect
|
// Start LED blink effect
|
||||||
blinker.blink();
|
blinker.blink();
|
||||||
|
|
||||||
// read button state
|
// Read button state
|
||||||
if (digitalRead(BUTTON_PIN) == LOW) {
|
if (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
// button is pressed
|
// Button is pressed
|
||||||
last = millis();
|
last = millis();
|
||||||
count++;
|
count++;
|
||||||
// wait until button is released
|
// Wait until button is released
|
||||||
while (digitalRead(BUTTON_PIN) == LOW) {
|
while (digitalRead(BUTTON_PIN) == LOW) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait PAUSE time before executing a command
|
// Wait PAUSE time before executing a command
|
||||||
if (count > 0 && (millis() - last) >= PAUSE) {
|
if (count > 0 && (millis() - last) >= PAUSE) {
|
||||||
// the switch case is the number of button presses
|
// The switch case is the number of button presses
|
||||||
switch (count) {
|
switch (count) {
|
||||||
case 1:
|
case 1:
|
||||||
DigiKeyboard.println(passwords[0]);
|
DigiKeyboard.println(passwords[0]);
|
||||||
|
|
@ -75,14 +93,14 @@ void loop() {
|
||||||
DigiKeyboard.println(passwords[2]);
|
DigiKeyboard.println(passwords[2]);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
// you can use print instead of println if you don't want to
|
// You can use print instead of println if you don't want
|
||||||
// hit enter automatically after inserting the password
|
// to hit enter automatically after inserting the password
|
||||||
DigiKeyboard.print(passwords[3]);
|
DigiKeyboard.print(passwords[3]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// reset the counter
|
// Reset the counter
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
Digispark_Passkey/LICENSE
Normal file
21
Digispark_Passkey/LICENSE
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2022 Johannes Findeisen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is furnished
|
||||||
|
to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||||
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||||
|
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
7
Digispark_Passkey/README.md
Normal file
7
Digispark_Passkey/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Digispark Passkey
|
||||||
|
|
||||||
|
The Passkey is a minimal device for storing passwords in an easy way.
|
||||||
|
|
||||||
|
**WARNING: No authentication nor encryption! All passwords are stored plain on the
|
||||||
|
device. Everybody who has access to it will have access to your stored passwords.**
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue