mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-25 17:09:44 +00:00
fix flake8 issues
This commit is contained in:
parent
d1800e0256
commit
307f7baecf
@ -25,17 +25,17 @@ def encode(s: bytes) -> str:
|
|||||||
# leftover bit of c1 and tack it onto c2. Then we take the 2 leftover
|
# leftover bit of c1 and tack it onto c2. Then we take the 2 leftover
|
||||||
# bits of c2 and tack them onto c3. The shifts and masks are intended
|
# bits of c2 and tack them onto c3. The shifts and masks are intended
|
||||||
# to give us values of exactly 5 bits in width.
|
# to give us values of exactly 5 bits in width.
|
||||||
c1, c2, c3 = unpack('!HHB', s[i*5:(i+1)*5])
|
c1, c2, c3 = unpack('!HHB', s[i * 5:(i + 1) * 5])
|
||||||
c2 += (c1 & 1) << 16 # 17 bits wide
|
c2 += (c1 & 1) << 16 # 17 bits wide
|
||||||
c3 += (c2 & 3) << 8 # 10 bits wide
|
c3 += (c2 & 3) << 8 # 10 bits wide
|
||||||
encoded += bytes([_b32tab[c1 >> 11], # bits 1 - 5
|
encoded += bytes([_b32tab[c1 >> 11], # bits 1 - 5
|
||||||
_b32tab[(c1 >> 6) & 0x1f], # bits 6 - 10
|
_b32tab[(c1 >> 6) & 0x1f], # bits 6 - 10
|
||||||
_b32tab[(c1 >> 1) & 0x1f], # bits 11 - 15
|
_b32tab[(c1 >> 1) & 0x1f], # bits 11 - 15
|
||||||
_b32tab[c2 >> 12], # bits 16 - 20 (1 - 5)
|
_b32tab[c2 >> 12], # bits 16 - 20 (1 - 5)
|
||||||
_b32tab[(c2 >> 7) & 0x1f], # bits 21 - 25 (6 - 10)
|
_b32tab[(c2 >> 7) & 0x1f], # bits 21 - 25 (6 - 10)
|
||||||
_b32tab[(c2 >> 2) & 0x1f], # bits 26 - 30 (11 - 15)
|
_b32tab[(c2 >> 2) & 0x1f], # bits 26 - 30 (11 - 15)
|
||||||
_b32tab[c3 >> 5], # bits 31 - 35 (1 - 5)
|
_b32tab[c3 >> 5], # bits 31 - 35 (1 - 5)
|
||||||
_b32tab[c3 & 0x1f], # bits 36 - 40 (1 - 5)
|
_b32tab[c3 & 0x1f], # bits 36 - 40 (1 - 5)
|
||||||
])
|
])
|
||||||
# Adjust for any leftover partial quanta
|
# Adjust for any leftover partial quanta
|
||||||
if leftover == 1:
|
if leftover == 1:
|
||||||
|
@ -24,12 +24,12 @@ class TestCryptoBase32(unittest.TestCase):
|
|||||||
|
|
||||||
(b'zlutoucky kun upel dabelske ody', 'PJWHK5DPOVRWW6JANN2W4IDVOBSWYIDEMFRGK3DTNNSSA33EPE======'),
|
(b'zlutoucky kun upel dabelske ody', 'PJWHK5DPOVRWW6JANN2W4IDVOBSWYIDEMFRGK3DTNNSSA33EPE======'),
|
||||||
|
|
||||||
(b'中文', '4S4K3ZUWQ4======'),
|
(b'中文', '4S4K3ZUWQ4======'), # noqa:E999
|
||||||
(b'中文1', '4S4K3ZUWQ4YQ===='),
|
(b'中文1', '4S4K3ZUWQ4YQ===='), # noqa:E999
|
||||||
(b'中文12', '4S4K3ZUWQ4YTE==='),
|
(b'中文12', '4S4K3ZUWQ4YTE==='), # noqa:E999
|
||||||
(b'aécio', 'MHB2SY3JN4======'),
|
(b'aécio', 'MHB2SY3JN4======'), # noqa:E999
|
||||||
(b'𠜎', '6CQJZDQ='),
|
(b'𠜎', '6CQJZDQ='), # noqa:E999
|
||||||
(b'Base64是一種基於64個可列印字元來表示二進制資料的表示方法',
|
(b'Base64是一種基於64個可列印字元來表示二進制資料的表示方法', # noqa:E999
|
||||||
'IJQXGZJWGTTJRL7EXCAOPKFO4WP3VZUWXQ3DJZMARPSY7L7FRCL6LDNQ4WWZPZMFQPSL5BXIUGUOPJF24S5IZ2MAWLSYRNXIWOD6NFUZ46NIJ2FBVDT2JOXGS246NM4V')
|
'IJQXGZJWGTTJRL7EXCAOPKFO4WP3VZUWXQ3DJZMARPSY7L7FRCL6LDNQ4WWZPZMFQPSL5BXIUGUOPJF24S5IZ2MAWLSYRNXIWOD6NFUZ46NIJ2FBVDT2JOXGS246NM4V')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user