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:
Vadim Yanitskiy
2020-05-10 02:32:46 +07:00
committed by laforge
parent d58c632277
commit eb06b45d0e

View File

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