Merge pull request #180 from betawave/str-bytes-conversion-fix
enable msg to be either string or bytes
This commit is contained in:
@@ -504,7 +504,7 @@ class VirtualICC(object):
|
||||
def __sendToVPICC(self, msg):
|
||||
""" Send a message to the vpcd """
|
||||
if isinstance(msg, str):
|
||||
self.sock.sendall(struct.pack('!H', len(msg)) + msg.encode())
|
||||
self.sock.sendall(struct.pack('!H', len(msg)) + bytes(map(ord,msg)))
|
||||
else:
|
||||
self.sock.sendall(struct.pack('!H', len(msg)) + msg)
|
||||
|
||||
|
||||
@@ -114,7 +114,10 @@ class RelayOS(SmartcardOS):
|
||||
|
||||
def execute(self, msg):
|
||||
# sendCommandAPDU() expects a list of APDU bytes
|
||||
apdu = map(ord, msg)
|
||||
if isinstance(msg,str):
|
||||
apdu = map(ord, msg)
|
||||
else:
|
||||
apdu = list(msg)
|
||||
|
||||
try:
|
||||
rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu)
|
||||
|
||||
Reference in New Issue
Block a user