base64编码总是一对一吗 [英] Is base64 encoding always one to one

查看:217
本文介绍了base64编码总是一对一吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为Base64编码算法的两个不同输入获得两个相同的编码值?

Is it possible to obtain two identical encoded values for two different inputs to the Base64 encoding algorithm?

例如,让我们使用另一种算法,该函数用字母X代替下划线.

Let's use another algorithm for example, a function that replaces underscores with the letter X.

Foo_Bar = FooXBar
FooXBar = FooXBar

Base64编码会发生这种情况吗?

Can this sort of thing ever happen with Base64 encoding?

推荐答案

不,它不会发生. Base64是无损转换(它甚至需要33%以上的空间).用数学术语来说,Base64函数是 bijection .

No, it cannot happen. Base64 is a lossless conversion (and it even needs a 33% space more). In math terms, the Base64 function is a bijection.

请注意 HTTP基本访问身份验证如何使用该编码来表示用户名和密码.任何人都可以从编码的字符串中获取原始字符串,因此,此身份验证仅应在HTTPS下使用.

Note how HTTP basic access authentication use this encoding for the username and the password. Anyone can get the original strings from the encoded one, and for this reason this authentication should be used only under HTTPS.

您还可以在维基百科上找到有关Base64的更多详细信息.

You can find more details on Base64 also on Wikipedia.

这篇关于base64编码总是一对一吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆