Error decoding password stored in mysql : binascii.Error: Incorrect padding

532 views
Skip to first unread message

uday bhaskar

unread,
Mar 14, 2018, 9:12:59 PM3/14/18
to Django users
Hello Everyone. 

I am trying to decode previously encoded and stored in mysql but ending up with binascii.Error: Incorrect padding error. I have been using sqllite for a while with same functionality used to work . When I changed to mysql it broke things . Any help with it is much appreciated. 


>>> dbins.user_pass
"b'ZWJzMTJndTFTJEhANUg=\\n'"

>>> base64.decodebytes(dbins.user_pass)
Traceback (most recent call last):
  File "D:\Development\sss\pyenv\lib\base64.py", line 517, in _input_type_check
    m = memoryview(s)
TypeError: memoryview: a bytes-like object is required, not 'str'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "D:\Development\sss\pyenv\lib\base64.py", line 552, in decodebytes
    _input_type_check(s)
  File "D:\Development\sss\pyenv\lib\base64.py", line 520, in _input_type_check
    raise TypeError(msg) from err
TypeError: expected bytes-like object, not str

>>> base64.decodebytes(dbins.user_pass.encode("utf-8"))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "D:\Development\sss\pyenv\lib\base64.py", line 553, in decodebytes
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

Thanks,
Uday.

Cictani

unread,
Mar 15, 2018, 1:28:52 AM3/15/18
to Django users
Hi,

try removing the \\n at the end it seems to be a bug or maybe while you exported it new lines were added and now you have these new lines in your password base64 strings.
Reply all
Reply to author
Forward
0 new messages