mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-16 18:38:32 +03:00
utils: fix list comprehension in h2s(): ignore upper case padding
By definition, h2s() is supposed to skip padding in the given hexstring, so it was working fine for 'ff', but not for 'FF'. Change-Id: I2c5d72a0f7f2796115116737f9f7b5299021f6a3 Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
This commit is contained in:
@@ -35,7 +35,8 @@ def i2h(s):
|
||||
return ''.join(['%02x'%(x) for x in s])
|
||||
|
||||
def h2s(s):
|
||||
return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2]) if not (x == 'f' and y == 'f') ])
|
||||
return ''.join([chr((int(x,16)<<4)+int(y,16)) for x,y in zip(s[0::2], s[1::2])
|
||||
if int(x + y, 16) != 0xff])
|
||||
|
||||
def s2h(s):
|
||||
return b2h(s)
|
||||
|
||||
Reference in New Issue
Block a user