哈希竞猜游戏系统开发(案例开发源码)

2022-06-30 15:46:34 浏览数 (1)

  哈希函数特点

  1.确定性

  如果两个哈希值不相同(根据同一函数),那么这两个哈希值的原始输入也是不相同的。

  2.散列碰撞

  哈希函数的输入和输出不是唯一对应关系的,如果两个哈希值相同,两个输入值很可能是相同的,但也可能不同。

  3.不可逆性

  哈希函数是一个单向密码体制,即从明文到密文的不可逆映射,只有加密过程没有解密过程。

  4.混淆特性

  输入一些数据计算出哈希值,然后部分改变输入值,一个具有强混淆特性的哈希函数会产生一个完全不同的哈希值。

  哈希简单的理解,就是把一串长的数据变成一串短的数据,它有三个特点:

  First,it is unidirectional.

  We can only calculate long data into a short hash.We can't deduce the original data from the hash.Many people are curious about how the blockchain is formed.For example,after the block is packaged,a hash will be calculated for the block,and the hash will be stored in the next block.The hash in the next block will lock the previous block.This is the traditional hash locking,The immutability of the blockchain comes from this.Because the previous block is changed,the hash in the subsequent block cannot be mapped.Therefore,the blockchain is the content locking of each block to the previous block,which is called hash locking.

  Second,hash is unique.

  The uniqueness of hash is that we turn a long data into a hash data,and each long data turns into a unique corresponding hash data.However,this sentence is problematic,because turning a long data into a short data or a long file into a short hash has a certain probability in science that it will form the same hash,but the probability is very low,This is how hashes are unique.

  Third,hash is discrete.

  Discreteness refers to two files that are very close to each other,or a long data that is only one digit different from each other.The hash values we calculate are vastly different and have no similarities.The discreteness of hash is mainly to avoid some characteristic attacks.

  常用哈希算法

  1.MD4

  MD4(RFC 1320)是MIT的Ronald L.Rivest在1990年设计的,MD是Message Digest(消息摘要)的缩写。哈希开发MrsFu123它适用在32位字长的处理器上用高速软件实现——它是基于32位操作数的位操作来实现的。

  2.MD5

  MD5(RFC 1321)是Rivest于1991年对MD4的改进版本。它对输入仍以512位分组,其输出是4个32位字的级联,与MD4相同。MD5比MD4来得复杂,并且速度较之要慢一点,但更安全,在抗分析和抗差分方面表现更好。

  3.SHA-1

  SHA1是由NIST NSA设计为同DSA一起使用的,它对长度小于264的输入,产生长度为160bit的散列值,因此抗穷举(brute-force)性更好。SHA-1设计时基于和MD4相同原理,并且模仿了该算法。

0 人点赞