What Are Hash Functions

Posted dadayan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了What Are Hash Functions相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

What are lazy variables?

[RxJS] What RxJS operators are

What SQL Statements Are Currently Running

What Are You Weighting For?

What Are You Weighting For?

Inner Functions - What Are They Good For?