剥离填充后解码 Base64
我正在从 Base64 编码字符串的末尾剥离填充。我发现我可以成功解码字符串,而无需首先添加填充(至少在 php 中)。这是 base64 规范的结果还是依赖于实现的结果?
还有一个相关的问题,除了作为填充之外,base64 编码的字符串中是否可以存在 =
符号,即如果它不依赖于实现,那么仅删除尾随的等号是否安全,或者是否有可能最后一个“真实”角色可能是一个吗?
I am stripping the padding from the end of of a base64 encoded string. I have found that I can successfully decode the string without adding the padding back on first (in php at least). Is this a result of the specification of base64 or implementation dependent?
And a related question, can a =
sign exist in a base64 encoded string other than as padding, i.e. If it is not implementation dependent, is it safe just to strip the trailing equals signs or is it possible that the last "real" character could have been one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然解码 Base64 字符串不需要填充,但如果删除填充,某些实现会引发错误。
RFC 规定:
= 字符仅用于填充。
While padding isn't necessary to decode a base64 string, there are some implementations that will throw an error if the padding has been stripped away.
The RFC states:
The = character will only ever be used for padding.