HTTP 基本身份验证中的 Base 64 编码

发布于 2024-10-31 08:46:47 字数 235 浏览 4 评论 0原文

我想知道使用 HTTP 基本身份验证时以 Base 64 编码字符串:“login:password”的目的是什么。

  • Base 64 通常用于通过纯 ASCII 协议发送二进制数据。但是登录:密码已经是一个字符串
  • 它几乎没有增加安全性
  • 输出比输入长,所以它不会提高性能

我可能错过了一些东西,因为目前在我看来这种编码只是增加了不必要的复杂性层。

谢谢

I am wondering what is the purpose of encoding the String: "login:password" in base 64 when using HTTP Basic Auth.

  • Base 64 is usually used to send binary data through ASCII only protocols. But the login:password is already a String
  • It adds practically no security
  • The output is longer than the input, so it does not improve performances

I am probably missing something since it does currently seems to me that this encoding just adds an unneeded layer of complexity.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最好是你 2024-11-07 08:46:47

来自http://en.wikipedia.org/wiki/Basic_access_authentication

安全并不是目的
编码步骤。相反,其意图是
编码是编码
非 HTTP 兼容字符
可能在用户名或密码中
转换为与 HTTP 兼容的内容。

From http://en.wikipedia.org/wiki/Basic_access_authentication

Security is not the intent of the
encoding step. Rather, the intent of
the encoding is to encode
non-HTTP-compatible characters that
may be in the user name or password
into those that are HTTP-compatible.

暮光沉寂 2024-11-07 08:46:47

我的第一个想法是,它以 Base64 进行编码,只是为了让它不那么明显,它实际上是一个用户名和密码。

其次,人们可以在密码中放入各种奇怪的字符——如果愿意的话,用 Base64 对其进行编码可以使数据采用一种不太“混乱”的格式。

此外,Base64 字符串输出的长度可以忽略不计;几个额外的数据包不会明显降低性能。

来自维基百科

虽然使用 Base64 算法对用户名和密码进行编码通常会使肉眼无法读取它们,但它们与编码一样容易解码。安全性不是编码步骤的目的。相反,编码的目的是将用户名或密码中可能存在的非 HTTP 兼容字符编码为 HTTP 兼容字符。

维基百科似乎证实了我最初的想法。干杯!

My first thought is that it's encoded in Base64 simply to make it less blatantly obvious that it's actually a username and a password.

Secondly, people can put all sorts of strange characters in their passwords -- encoding it in Base64 puts the data in a format that is less "messy", if you will.

Also, the length of the output in the Base64 string is fairly negligible; a couple extra packets of data isn't going to degrade performance any noticeable amount.

From Wikipedia:

While encoding the user name and password with the Base64 algorithm typically makes them unreadable by the naked eye, they are as easily decoded as they are encoded. Security is not the intent of the encoding step. Rather, the intent of the encoding is to encode non-HTTP-compatible characters that may be in the user name or password into those that are HTTP-compatible.

Wikipedia seems to confirm my initial thoughts. Cheers!

面犯桃花 2024-11-07 08:46:47

使用 Base64 编码后,通常会通过 SSL 连接进行连接,然后加密编码的用户名和密码以提高安全性。

The encoding with base64 is usually followed up by connecting through an SSL connection, which will then encrypt the encoded username and password for additional security.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文