如何创建固定长度的解密

huangapple go评论57阅读模式
英文:

How to create fixed length decryption

问题

我想问一下是否有一种方法可以加密文本(无论多长),并始终获得固定长度的解密?我指的不是哈希,而是加密/解密。

示例:
假设我们想加密(而不是哈希)一个60个字符长的文本。结果将是一个长度为32个字符的字符串。然后我们可以解密该字符串以获取原始文本!

现在我们想要加密(而不是哈希)一个200个字符长的文本。结果将是一个再次为32个字符长的字符串。然后我们可以解密该字符串以获取原始文本!

这种可能吗?

谢谢

英文:

I would like to ask if there is a way to encrypt text (no matter how long it is) and ALWAYS get a fixed length decryption? I am not referring to hashing but to encryption/decryption.

Example:
Suppose that we want to encrypt (not hash) a text which is 60 characters long. The result will be a string which is 32 characters long. We can then decrypt the string to get the original text!

We now want to encrypt (not hash) a text which is 200 characters long. The result will be a string which is again 32 characters long. We can then decrypt the string to get the original text!

Is that somehow possible?

Thank you

答案1

得分: 2

根据评论的指示,这是不可能的。关于为什么不可能的根本原因,请参见鸽巢原理。在您的示例中,有256^200个输入和256^32个输出。因此,必须至少有一个输出具有多于一个输入,因此不可能逆转。由于输入的数量远远大于输出的数量(在一般情况下是无限的),几乎所有的密文都是不可能解密的。

英文:

As the comments indicate, this is impossible. For the underlying reason that this is impossible, see the Pigeonhole Principle. In your example, there are 256^200 inputs and 256^32 outputs. Therefore there must be at least 1 output that has more than 1 input, and therefore is impossible to reverse. Since the number of inputs is massively larger than the number of outputs (and in the general case, is unbounded), almost all cipher texts are necessarily impossible to decrypt.

huangapple
  • 本文由 发表于 2023年2月19日 07:03:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75496923.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定