简体   繁体   English

128位可逆加密器/哈希器以减小数据库大小

[英]128 bit reversible encryptor/hasher to reduce DB size

Is there anything out there for PHP that can hash/encrypt a long string into a 128 bit string that can also be reversed? PHP是否可以将长字符串哈希/加密为也可以反转的128位字符串?

I am trying importing hundreds on millions of strings into a MySQL DB and the average string is over 100 characters, MD5 gets this down to 32 characters which significantly reduces storage however I cannot reverse this again in my application. 我正在尝试将数以亿计的字符串导入MySQL数据库,平均字符串超过100个字符,MD5将其降至32个字符,这大大减少了存储空间,但是我无法在应用程序中再次将其反转。

Does PHP have anything available that can handle this? PHP是否有任何可用的方法可以解决此问题?

If I understand your question correctly, it seems to me you mix up hashing and compression quite a lot. 如果我正确理解了您的问题,在我看来,您将哈希和压缩混为一谈。

Most hash-functions are not easily reversible, because that is not their purpose. 大多数哈希函数不容易逆,因为这不是它们的目的。 There are infinite "Strings/ByteStreams/Numbers/..." that correspond to the result of a hash-function. 有无限的“字符串/字节流/数字/ ...”对应于哈希函数的结果。 As you may know, even images that are a few Gigabytes big, also give you an md5sum of 32 characters. 如您所知,即使是几千兆字节的图像,也会给您带来32个字符的md5sum。

You can not just magically map any String into a String of fixed length that is shorter, to just be able to magically pouff it back to its original String. 您不仅可以将任何String神奇地映射到较短长度的固定长度的String中,还可以神奇地将其返回原来的String中。

It may well be, that some hash-functions could very efficiently be used to reverse their process if you know that your target results have to have this and that property (in you case maybe character-length of 100-120), but I doubt it. 如果您知道目标结果必须具有该属性和该属性(在您的情况下,字符长度为100-120),则很有可能将某些哈希函数有效地用于逆转其过程。它。

Or do I totally misunderstand and you just mean ASCII-Strings with the expression "128 bit string"? 还是我完全误解了,您只是用表达式“ 128位字符串”来表示ASCII字符串?

不,您不能这样做: 鸽洞原理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM