mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 15:08:25 +00:00
Further bugfix; convert first, then check length
This commit is contained in:
@@ -414,12 +414,17 @@ class DecodeQR:
|
||||
pass
|
||||
|
||||
# Is it byte data?
|
||||
if not isinstance(s, bytes):
|
||||
try:
|
||||
# TODO: remove this check & conversion once above cast to str is removed
|
||||
s = s.encode()
|
||||
except UnicodeError:
|
||||
# Couldn't convert back to bytes; shouldn't happen
|
||||
raise Exception("Conversion to bytes failed")
|
||||
|
||||
# 32 bytes for 24-word CompactSeedQR; 16 bytes for 12-word CompactSeedQR
|
||||
if len(s) == 32 or len(s) == 16:
|
||||
try:
|
||||
if not isinstance(s, bytes):
|
||||
# TODO: remove this check & conversion once above cast to str is removed
|
||||
s = s.encode()
|
||||
bitstream = ""
|
||||
for b in s:
|
||||
bitstream += bin(b).lstrip('0b').zfill(8)
|
||||
|
||||
Reference in New Issue
Block a user