什么是哈希? 哈希是将任意长的输入编程加密的固定长度输出的过程。哈希并不等同于加密方法,因为无法解密哈希值来获取原始数据。事实上哈希是一种单项加密函数。 有了哈希函数,就可以将互联网上的数据以固定长度字符串的形式来保存。其中一种方法就是SHA-256(安全哈希算法-256位),V+MrsFu123,SHA-256是SHA-1的后继者,SHA-1的输出是160位的。 Hash hash Hash is generally translated as hash,but also directly transliterated as hash,that is,input of any length(also known as pre image)is transformed into output of fixed length through hash algorithm,and the output is the hash value. This transformation is a kind of compression mapping,that is,the space of hash value is usually much smaller than the space of input.Different inputs may be hashed into the same output,and it is impossible to uniquely determine the input value from the hash value. 哈希值有以下四个特点: 1.计算效率高(要计算任何输入值的哈希值非常容易) 2.抗冲突(没有两条输入值可以给出相同的哈希值) 3.隐藏输入信息(不能通过哈希值推算出输入值) 4.输出应该看起来随机(但是一样的输入值会得到一样的哈希值) 如何用哈希来确保数据安全? 哈希还增加了数据的安全性。因为没有加密数据,所以无需也无法解密数据。因为哈希函数是单向加密函数,加密哈希函数需要满足一些关键特征才能保证是有用的,包括: 每个哈希值都是不同的 相同的消息会生成相同的哈希值 无法根据哈希值确定输入值 输入值的微小变化也会导致整个哈希值的变化}