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.

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

时间: 2024-08-29 05:13:56

What Are Hash Functions的相关文章

java之Secure hash functions

java之Secure hash functions A secure hash function will generate a large number, called the hash value, when given a document of some sort. This document can be of almost any type. We will be using simple strings in our examples. The function is a one

IA_11.3散列函数Hash functions

Hash function

Hash function From Wikipedia, the free encyclopedia A hash function that maps names to integers from 0 to 15. There is a collision between keys "John Smith" and "Sandra Dee". A hash function is any function that maps data of arbitrary

[转]加盐hash保存密码的正确方式

0x00 背景 大多数的web开发者都会遇到设计用户账号系统的需求.账号系统最重要的一个方面就是如何保护用户的密码.一些大公司的用户数据库泄露事件也时有发生,所以我们必须采取一些措施来保护用户的密码,即使网站被攻破的情况下也不会造成较大的危害.保护密码最好的的方式就是使用带盐的密码hash(salted password hashing).对密码进行hash操作是一件很简单的事情,但是很多人都犯了错.接下来我希望可以详细的阐述如何恰当的对密码进行hash,以及为什么要这样做. 0x01 重要提醒

HashMap实现 Hash优化与高效散列

OverView Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap class is roughly equivalent to Hashtable, except that it is unsynch

Bloom filter的实现以及常用的hash函数

bloom filter利用时间换空间的思想,利用多个哈希函数,将一个元素的存在状态映射到多个bit中,特别是在网络环境中,BF具有广泛的用途,关键问题就是要减少false positive rate(可以设置参数来调节),扩展有 counting BF.这里选用的hash函数是表现较好的 BKDRHash , SDBMHash, DJBHash . Bloom-filter代码: bloom_filter.h #ifndef __BLOOM_FILTER_H__ #define __BLOOM

Hash Table

1.Hash functions 直接定址法:h(k)=ak+b. 数字分析法 平方取中法:去关键字平方后的中间几位为hash address. 折叠法:将关键字分割成位数相同的几部分(最后一部分位数可以不同),然后取这几部分的叠加(去掉进位)和作为hash address. 除留余数法:h(k)=k mod m, m<=Table.length.一般情况下,取m为质数或不包含小于20的质因数的合数. 随机数法:h(k)=random(k), 当关键字长度不同时采用此法较恰当. 乘法散列法(mu

Algorithm | hash

A basic requirement is that the function should provide a uniform distribution of hash values. A non-uniform distribution increases the number of collisions and the cost of resolving them. A critical statistic for a hash table is called the load fact

hash codes in java I : gneral usage and how to produce hash codes

What is the use of hash codes in Java? Java uses hash codes for the same reason described above—to efficiently retrieve data from hash based collections. If the objects of your class are not used as keys in a hash based collection, for example, in a