enable msg to be either string or bytes

This commit is contained in:
Leonard Hübner
2020-10-15 18:52:46 +02:00
parent d7d21fa802
commit 97194d230d
2 changed files with 5 additions and 2 deletions

View File

@@ -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)

View File

@@ -114,7 +114,10 @@ class RelayOS(SmartcardOS):
def execute(self, msg):
# sendCommandAPDU() expects a list of APDU bytes
if isinstance(msg,str):
apdu = map(ord, msg)
else:
apdu = list(msg)
try:
rapdu, sw1, sw2 = self.session.sendCommandAPDU(apdu)