- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Python
The common Python module for Smart Card programming is 'pyscard'. The import statement is:
import smartcard
Although the programmer must still interact with the card by sending APDUs, this is done by declaring variables as arrays of machine code values.
SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
DF_TELECOM = [0x7F, 0x10]
Detecting Smart Card reader devices:
from smartcard.System import readers
r = readers()
print r
Connecting to a Smart Card:
connection = r[0].createConnection()
connection.connect()
SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
DF_TELECOM = [0x7F, 0x10]
data, sw1, sw2 = connection.transmit( SELECT + DF_TELECOM )
print "%x %x" % (sw1, sw2)
AUSSEL, J, D. ROUSSEAU, L. 2014. pyscard - Python for smart cards. pyscard user’s guide. [WWW]. https://pyscard.sourceforge.io/user-guide.html. 21st March 2017.