码迷,mamicode.com
首页 > 其他好文 > 详细

What Are Hash Functions

时间:2018-04-29 15:19:44      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:ash   find   receive   sim   not   char   value   orm   ssi   

What Are Hash Functions

A hash function is simply a function that takes in input value, and from that input creates an output value deterministic of the input value. For any x input value, you will always receive the same y output value whenever the hash function is run. In this way, every input has a determined output. 

A function is basically something that takes an input and from that input derives an output. 

技术分享图片

A hash function is therefore something that takes an input (which can be any data - numbers, files, etc) and outputs a hash. A hash is usually displayed as a hexadecimal number.

技术分享图片

This is the hash function md5, which from any input data creates a 32 character hexadecimal output. Hash functions are generally irreversible (one-way), which means you can’t figure out the input if you only know the output – unless you try every possible input (which is called a brute-force attack). 

Hash functions are often used for proving that something is the same as something else, without revealing the information beforehand. Here’s an example.

Let’s say Alice is bragging to Bob that she knows the answer to the challenge question in their Math class. Bob wants her to prove that she knows the answer, without her telling him what it is. So, Alice hashes her answer (let’s say the answer was 42) to produce this hash:

技术分享图片

Alice gives this hash to Bob. Bob can not find out what the answer is from this hash – but when he finds the answer himself, he can hash his answer and if he gets the same result, then he knows that Alice did indeed have the answer. Hashes are often used in this context of verifying information without revealing it to the party that is verifying.

What Are Hash Functions

标签:ash   find   receive   sim   not   char   value   orm   ssi   

原文地址:https://www.cnblogs.com/dadayan/p/8970942.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!