混淆了哈希 [英] Confused about hashes

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

问题描述

说我有一个文字一个5000个字符的斑点。我通过散列程序运行它,并生成一个40个字符长的散列。现在我运行另一个文本块,10000个字符。它仍然会生成一个40个字符的散列。对于任何长度的文本都是如此。



我的问题是,如果哈希是唯一的,我不能将任何东西压缩到40个字符串中?

解决方案

>

您可以将任何人压缩到一个(非常)独特的指纹。但是,您无法单独通过指纹识别某人是谁。这就像一个散列,你可以很容易地找出 hash(abcdef) - > a1b2c3 ,但只给出 a1b2c3 ,您无法轻易告诉源数据。



为了反转指纹,您需要将指纹与已知 people->指纹的数据库进行比较(如果未知指纹匹配Person1,则未知指纹属于他们)

使用散列,你必须再次做同样的事情 - 你有一个包含所有字符串 - >散列映射的数据库(称为彩虹表)。然后,你用哈希a1b2c3查找该行,并显示abcdef被散列以获得该信息。另一种更常见的方式是简单地尝试每个字符组合,对它们进行散列和比较(蛮力攻击<最后,尽管人类指纹是独特的,但可能有两个相同的东西,但它非常不可能 - 这与散列法是一样的。一些哈希算法比其他哈希算法更容易受到碰撞的影响。


我的问题是,如果哈希是唯一的,我不能将任何东西压缩到40个字符串中?




理论上哈希是一种很好的压缩方法,但解压缩超过(比如说)10个ASCII字符的数据是非常不切实际的。你是对的,你可以压缩任何东西到40个字符的字符串,但你不能实际解压缩它(即使理论上是一点点的)一拉伸......)


say I have a blob of text 5000 characters. I run it through a hashing program and generates a 40 char long hash. now i run another blob of text, 10000 characters. it still generates a hash 40 chars long. that's true for text of any length.

my question is if the hashes are all unique, wouldn't i be able to compress anything into a 40 char string?

解决方案

One way to think of a hash is like a human fingerprint (hashes are also sometimes referred to as fingerprints)..

You can "compress" any person in to a (pretty much) unique finger-print.. but, you cannot know who someone is by their fingerprint alone.. This is just like a hash, you can easily work out hash("abcdef") -> a1b2c3, but given only a1b2c3, you cannot trivially tell the source data.

To reverse a finger print, you need to compare the fingerprint to a database of known people->finger-prints (if the unknown fingerprint matches Person1, the unknown fingerprint belongs to them)

With a hash, again you must do much the same thing - you have a database with all string->hash mappings (called a rainbow table). Then you lookup the row with the hash "a1b2c3" and it shows "abcdef" was hashed in order to get this. The other more common way is to simply try every combination of characters, hash them and compare (a brute force attack)

Finally, while human fingerprints are "unique", it's possible to have two the same, it's just incredibly unlikely - it's the same with hashing... Some hashing algorithms are more susceptible to collisions than others.

my question is if the hashes are all unique, wouldn't i be able to compress anything into a 40 char string?

Theoretically hashing is a great compression method, but to decompress is incredibly impractical beyond (say) 10 ASCII characters of data.. You're right, you can compress anything to a 40 character string, but you cannot decompress it practically (even theoretically is a bit of a stretch..)

这篇关于混淆了哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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