Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder returns empty array #34

Closed
za3k opened this issue Jun 9, 2021 · 3 comments
Closed

Encoder returns empty array #34

za3k opened this issue Jun 9, 2021 · 3 comments

Comments

@za3k
Copy link

za3k commented Jun 9, 2021

This code:

import reedsolo
reedsolo.RSCodec(300).encode(b'a')

Returns bytearray(b'') on my computer. Adjusting the number down causes it to return something.

za3k added a commit to za3k/qr-backup that referenced this issue Jun 9, 2021
IMPORTANT: This doesn't work currently. There seems to be a bug in the reedsolo library. It has been reported at tomerfiliba-org/reedsolomon#34

This required removing the proprocessing step of base64 encoding. Instead, we base64 encode each QR code independently (always). Sadly this does make the data a little less readable while debugging.
Closes #2.
@za3k
Copy link
Author

za3k commented Jun 9, 2021

Oh also, in case it's an issue with potential string lengths, reedsolo.RSCodec(300, c_exp=12).encode(b'a') instead outputs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 893, in encode
    enc.extend(rs_encode_msg(chunk, self.nsym, fcr=self.fcr, generator=self.generator, gen=self.gen[nsym]))
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 514, in rs_encode_msg
    msg_in = _bytearray(msg_in)
  File "/usr/lib/python3.9/site-packages/reedsolo.py", line 279, in _bytearray
    return array("i", obj)
ValueError: bytes length not a multiple of item size

@lrq3000
Copy link
Collaborator

lrq3000 commented Dec 9, 2022

About your first question, it's an uncaught error but it's normal, this happens because you initialized RSCodec with too many ECC symbols (300) when by default the max total message length nsize=255. Now there will be an error message.

About your second question, this was indeed a bug, which was kindly fixed by someone else in #46 and is now merged, so this bug does not happen anymore.

@lrq3000 lrq3000 reopened this Dec 9, 2022
@lrq3000 lrq3000 closed this as completed Dec 9, 2022
@za3k
Copy link
Author

za3k commented Dec 9, 2022

Thanks for adding an error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants