python – Python:base64解码时忽略“错误填充”错误
问题:
我有一些base64编码的数据,即使其中存在填充错误,我也想将其转换回二进制。 如果我用
base64.decodestring(b64_string)
会引发“填充错误”错误。 还有另一种方法吗?
更新:感谢您的所有反馈。 老实说,提到的所有方法听起来都有些失败,所以我决定尝试使用openssl。 以下命令可以有效地解决问题:
openssl enc -d -base64 -in b64string -out binary_data
I have some data that is base64 encoded that I want to convert back to binary even if there is a padding error in it.If I useit raises an ‘Incorrect padding’ error.Is there another way?UPDATE: Thanks for all the feedback.To be honest, all the methods mentioned sounded a bit hit and miss so I decided to try openssl.The following command worked a treat: