突然发现只要 = 多余两个就行
Topic source因为base64是以三个字节为一组,所以不满一组只有缺一个或缺两个字节的情况 因此base64末尾会出现 0-2 个 '=',最多两个 因为base64的64个字符中没有'=',所以多余的'='解码是 '' <code>def b64decode(s, altchars=None, validate=False):</code> 因为 b64decode 函数默认是不验证解码字符串的格式的,所以只要解码字符串的位数补全了,后面再多的'='都不影响解码
如果有不对的地方,请指正。
>>> base64.urlsafe_b64decode('YWJjZA==')
b'abcd'
>>> base64.urlsafe_b64decode('YWJjZA===')
b'abcd'
>>> base64.urlsafe_b64decode('YWJjZA=======')
b'abcd'
>>> base64.urlsafe_b64decode('abcd=======')
b'i\xb7\x1d'
>>> base64.urlsafe_b64decode('abcd=')
b'i\xb7\x1d'
>>> base64.urlsafe_b64decode('abcd')
b'i\xb7\x1d'
- 1
苏生不语_