Created
November 19, 2019 18:03
-
-
Save wesleyit/4aa2bf0a79d11866142bfa4477282c2a to your computer and use it in GitHub Desktop.
Type your password if an authorized UID is read by NFC reader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import time | |
import serial | |
import pykeyboard | |
k = pykeyboard.PyKeyboard() | |
ENTER = k.enter_key | |
password = 'My_Super_P4SSWoRD' | |
print('Starting serial device...') | |
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600) | |
def main(): | |
time.sleep(1) | |
print('Waiting for a card...') | |
card = ser.readline().decode() | |
print('Got a card. Decoding...') | |
card = re.findall(r'[0-9]+', card)[0] | |
print('UID: ', card) | |
valid_uids = ['8112916219', '8410315760', '4649650'] | |
if card in valid_uids: | |
print('Access granted.') | |
k.type_string(password) | |
k.tap_key(ENTER) | |
else: | |
print('Access denied.') | |
if __name__ == '__main__': | |
while True: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment