哈希到底是什么?
我正在学习MD5。我在MD5的大部分描述中发现了一个术语“哈希”。我用谷歌搜索“哈希”,但在计算机编程中找不到“哈希”的确切术语。
为什么我们在计算机编程中使用“哈希”?这个词的由来是什么??
I am learning MD5. I found a term 'hash' in most description of MD5. I googled 'hash', but I could not find exact term of 'hash' in computer programming.
Why are we using 'hash' in computer programming? What is origin of the word??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我想说任何答案都必须是猜测,所以我会将其设为社区维基。
薯条或薯煎饼是一种早餐食品,将土豆切成细长条(比炸薯条小,也更短,但比例相似),然后用动物或植物脂肪将大量条煎至棕色、粘在一起并煮熟。 。类似地,“散列”一个数字意味着使用仍然确定地取决于输入数字的方法将其转换为另一个通常更小的数字。
我相信“哈希”这个术语首先是在“哈希表”的上下文中使用的,“哈希表”在 20 世纪 60 年代的大型机上普遍使用。在这些情况下,通常将大范围的整数值转换为小整数的“哈希表索引”。对于高效的哈希表来说,“哈希函数”均匀分布或“平坦”非常重要。
我没有引用,自从我在 80 年代听到这个类比以来,这就是我对这个类比的理解。不过,当这个词第一次被应用时,一定有人在那里。
I would say any answer must be guesswork, so I will make this a community wiki.
Hash, or hash browns, is breakfast food made from cutting potatoes into long thin strips (smaller than french fries, and shorter, but proportionally similar), then frying the mass of strips in animal or vegetable fat until browned, stuck together, and cooked. By analogy, 'hashing' a number meant turning it into another, usually smaller, number using a method which still deterministically depending on the input number.
I believe the term "hash" was first used in the context of "hash table", which was commonly used in the 1960's on mainframe-type machines. In these cases, usually an integer value with a large range is converted to a "hash table index" which is a small integer. It is important for an efficient hash table that the "hash function" be evenly distributed, or "flat."
I don't have a citation, that is how I have understood the analogy since I heard it in the 80's. Someone must have been there when the term was first applied, though.
您指的是“哈希函数”。它用于为给定的参数集生成唯一值。
哈希的一大用途是密码安全。您无需将密码保存在数据库中,而是保存密码的哈希值。
You're refering to the "hash function". It is used to generate a unique value for a given set of parameters.
One great use of a hash is password security. Instead of saving a password in a database, you save a hash of the password.
哈希应该是从 00 到 FF(十六进制)的值的唯一组合,表示特定的数据片段,无论是文件还是字节字符串。它主要用于密码存储和验证,并测试一个文件是否与另一个文件相同(即,对两个文件进行哈希处理,如果它们匹配,则它们是同一个文件)。
一般来说,任何 SHA 算法都优于 MD5,因为使用它时可能会发生哈希冲突。请参阅这篇维基百科文章。
A hash is supposed to be a unique combination of values from 00 to FF (hexadecimal) that represents a certain piece of data, be it a file or a string of bytes. It is used primarily for password storage and verification, and to test if a file is the same as another file (i.e. you hash two files, if they match, they're the same file).
Generally, any of the SHA algorithms are preferred over MD5, due to hash collisions that can occur when using it. See this Wikipedia article.
根据维基百科有关哈希函数的文章,Donald Knuth 在《计算机编程艺术》中能够将哈希函数的概念追溯到 Hans Peter Luhn 在 1953 年撰写的 IBM 内部备忘录
。只是为了好玩,这里引用了 克朗代克的两个女人:阿拉斯加金矿之旅的故事 (1899) :
According to the Wikipedia article on hash functions, Donald Knuth in the Art of Computer Programming was able to trace the concept of hash functions back to an internal IBM memo by Hans Peter Luhn in 1953.
And just for fun, here's a scrap of overheard conversation quoted in Two Women in the Klondike: the Story of a Journey to the Gold Fields of Alaska (1899):
哈希函数将输入哈希为值,需要 salt 值并且没有证明需要盐来储存。迹象是每个人都说我们必须储存盐同时匹配和新的仍然工作。数学相关的概念是双射
the hash function hashes input to a value, requires a salt value and no proof salt is needed to store. Indications are everybody says we must store the salt same time match and new still work. Mathematically related concept is bijection
添加到 gabriel1836 的答案中,哈希函数的重要属性之一是它是单向函数,这意味着您无法从其哈希值生成原始字符串。
adding to gabriel1836's answer, one of the important properties of hash function is that it is a one way function, which means you cannot generate the original string from its hash value.