Skip to content

Instantly share code, notes, and snippets.

@Achifaifa
Created July 18, 2014 16:45
Show Gist options
  • Save Achifaifa/96d533dddcee2147c9e1 to your computer and use it in GitHub Desktop.
Save Achifaifa/96d533dddcee2147c9e1 to your computer and use it in GitHub Desktop.
This code reads and displays data from Spanish social security magnetic cards.
#!/usr/bin/env python
import os, sys, termios, tty
def getch():
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
try:
tty.setraw(fd)
return sys.stdin.read(33)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old)
os.system('clear')
while 1:
data=getch()
data=data.split(')')
print "\n?: %s" %data[0][:-8]
print "SSN: %s" %data[0][-8:]
print "?: %s" %data[1]
print "Expiry: W%s, %s" %(data[2][:-4],data[2][-4:])
print "B date: %s/%s/%s" %(data[3][-4:],data[3][-2:],data[3][:-2])
print "?: %s\n" %(data[4])
print "==========================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment