aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2010-12-06 20:07:22 +0100
committerSylvain Munaut <tnt@246tNt.com>2010-12-06 20:07:22 +0100
commitbe17997e55cb5544d3cc74c981b4d605b9e0a7dc (patch)
treebc43fef50cd76b9eaa0b353ef73360ee56133992
parent6576ce18868baab6aca98d0d23997228c389a791 (diff)
Add a internal h2i purely for symmetry :)
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rwxr-xr-xpySim.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/pySim.py b/pySim.py
index 75e93ad..72ae318 100755
--- a/pySim.py
+++ b/pySim.py
@@ -31,7 +31,6 @@ import sys
from smartcard.Exceptions import NoCardException
from smartcard.System import readers
from smartcard.CardConnectionObserver import ConsoleCardConnectionObserver
-from smartcard.util import toBytes
# ----------------------------------------------------------------------------
@@ -44,6 +43,9 @@ def h2b(s):
def b2h(s):
return ''.join(['%02x'%ord(x) for x in s])
+def h2i(s):
+ return [(int(x,16)<<4)+int(y,16) for x,y in zip(s[0::2], s[1::2])]
+
def i2h(s):
return ''.join(['%02x'%(x) for x in s])
@@ -307,7 +309,7 @@ class PcscSimLink(object):
data : string (in hex) of returned data (ex. "074F4EFFFF")
sw : string (in hex) of status word (ex. "9000")
"""
- apdu = toBytes(pdu)
+ apdu = h2i(pdu)
data, sw1, sw2 = self._con.transmit(apdu)