Last active
January 18, 2019 08:51
-
-
Save tom-monaco/9e9e906785c9f818eca4d345866567e9 to your computer and use it in GitHub Desktop.
simple parser for cheap usb magnetic strip readers. this is aimed at the person who's simply curious about the data on the tracks of the strip.
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
while True: | |
terminal_input = input("scan code:") | |
if (terminal_input == None): | |
break | |
t1begin = terminal_input.find('%') + 1 | |
t1end = terminal_input.find('?;', t1begin) | |
t2begin = terminal_input.find('?;') +2 | |
t2end = terminal_input.find('?;', t2begin) | |
t3end = terminal_input.rfind('?') | |
t3begin = terminal_input.rfind("?;", None, t3end) + 2 | |
if t1begin > 0 and t1end > t1begin: | |
try: | |
track1 = terminal_input[t1begin:t1end] | |
print('Track 1: ' + track1) | |
except: | |
print('Track 1 READ ERROR') | |
if t2begin > 0 and t2end > t2begin: | |
try: | |
track2 = terminal_input[t2begin:t2end] | |
print('Track 2: ' + track2) | |
except: | |
print('Track 2 READ ERROR') | |
if t3begin > 0 and t3end > t3begin: | |
try: | |
track3 = terminal_input[t3begin:t3end] | |
print('Track 3: ' + track3) | |
except: | |
print('Track 3 READ ERROR') | |
print('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment