colinta / SublimeStringEncode

Converts characters from one "encoding" to another using a transformation (think HTML entities, not character encodings)
Other
150 stars 22 forks source link

Base64 Decode requires padding #37

Closed scholtes closed 6 years ago

scholtes commented 6 years ago

Base64 Decode will not decode strings with the padding characters removed.

As the padding characters are technically not required to decode without ambiguity, many applications strip the padding after encoding.

A quick fix would be to change the following line (here):

return base64.b64decode(text).decode('raw_unicode_escape')

to this:

return base64.b64decode(text + '===').decode('raw_unicode_escape')

(Per this gist, excess padding is safely ignored. More tips and tricks in that link).

A Sublime user can work around this by manually typing in the padding before using this feature, but I think adding this redundancy could benefit the overall ease of use (and hopefully not break anyone's workflow).

colinta commented 6 years ago

A pull request would be most welcome! I'll try to add this fix, but it hasn't come up before.