Skip to content

Commit

Permalink
Merge pull request #14 from jgiannuzzi/longstring-toBytes
Browse files Browse the repository at this point in the history
Fix toBytes regression
  • Loading branch information
LudovicRousseau committed Oct 9, 2015
2 parents 11502a1 + b7dc50a commit 680e400
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion smartcard/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def toBytes(bytestring):
>>> toBytes("3B6500 009C1101 0103")
[59, 101, 0, 0, 156, 17, 1, 1, 3]
"""
packedstring = bytestring.replace(' ', '').replace(' ','')
packedstring = bytestring.replace(' ', '').replace(' ','').replace('\n', '')
try:
return list(map(lambda x: int(''.join(x), 16), zip(*[iter(packedstring)] * 2)))
except KeyError:
Expand Down
6 changes: 6 additions & 0 deletions test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def test_toBytes(self):
data_in = "3B6500 009C1101 0103"
self.assertEqual(toBytes(data_in), data_out)

data_in = '''
3B 65 00
00 9C 11 01
01 03
'''
self.assertEqual(toBytes(data_in), data_out)

def test_padd(self):
data_in = toBytes("3B 65 00 00 9C 11 01 01 03")
Expand Down

0 comments on commit 680e400

Please sign in to comment.