0

I am receiving json data that is base64 encoded and I am supposed to decode it using Python. For most base64 requests, everything works fine, but some requests contains some strange chars after decoding.

The thing is, in Python I am getting an error (Invalid padding), even though the padding is right, but if I try to decode the base64 with the unix command or on https://www.base64decode.org/ website, I get all the data from the base64.

Do you know any work around for this problem, beside calling the unix command from python code?

Thank you!

khelwood
  • 55,782
  • 14
  • 81
  • 108
robertg
  • 73
  • 1
  • 8
  • Does this answer your question? [Python: Ignore 'Incorrect padding' error when base64 decoding](https://stackoverflow.com/questions/2941995/python-ignore-incorrect-padding-error-when-base64-decoding) – J'e Oct 08 '20 at 13:54
  • I already took a look on that link and is not solving my problem, I am assuming that maybe is something wrong with the python library. – robertg Oct 08 '20 at 15:56
  • can you share an example that causes 'invalid padding' error, even though the padding is right and one that shows some strange chars? – jps Oct 08 '20 at 16:14
  • Unfortunately, I cannot share the data due to privacy reasons. I tried to decode it on https://www.base64encode.org/ and anonymize the data fields and convert it back to base64. The problem is, after doing that, the base64 is valid and I can decode it in python. – robertg Oct 08 '20 at 18:34

0 Answers0