为什么命令行计算的base64字符串与curl计算的base64字符串不同?
真的很困惑 - 猜猜这与最后的单个字符放置有关,或者可能与我不知道的基本摘要完成的填充有关..?
因此,如果我执行此操作,您可以看到 Base64 编码的结果:
echo '[email protected]:password' | openssl enc -base64
aG9zdEBtYWlsLmNvbTpwYXNzd29yZAo=
现在,如果我发出curl 请求:
curl -v -u [email protected]:password https://
aG9zdEBtYWlsLmNvbTpwYXNzd29yZA==
您会注意到 Base64 字符串不相同..哈哈什么? Base64 命令行实际上是不正确的 - 如果您在请求中替换它,则会失败。那么 - 基本摘要不真正使用 base64 字符串吗?我注意到总是在字符串末尾执行 ao= 而不是 == ...
还有想法吗?
编辑:所以,这是来自 echo 的尾随换行符: -n 不输出尾随换行符,
谢谢!
Really confused - Guess it has to do with a single character placement at the end, or possible padding done with basic digest that I'm not aware of..?
So, if I execute this, you can see the product of the base64 encode:
echo '[email protected]:password' | openssl enc -base64
aG9zdEBtYWlsLmNvbTpwYXNzd29yZAo=
Now, if I make a curl request:
curl -v -u [email protected]:password https://
aG9zdEBtYWlsLmNvbTpwYXNzd29yZA==
You'll notice that the base64 strings are NOT the same..haha what? The base64 command line one is actually incorrect - if you substitute that in the request, it fails. SO - does basic digest NOT truly use a base64 string? I'm noticing that is always doing a o= instead of == at the end of the string ...
And ideas?
EDIT: So, it was the trailing newline from echo:
-n do not output the trailing newline
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请尝试使用
echo -n
来代替。Try
echo -n
instead.