当前位置:网站首页>什么是区块哈希竞猜游戏系统开发?哈希竞猜游戏系统开发(案例成熟)
什么是区块哈希竞猜游戏系统开发?哈希竞猜游戏系统开发(案例成熟)
2022-07-04 18:45:00 【VC_MrsFu123】
01.Hash函数
单向散列函数,又称单向Hash函数、杂凑函数,就是把任意长度的输入消息串变化成固定长的输出串且由输出串难以得到输入串的一种函数。这个输出串称为该消息的散列值。一般用于产生消息摘要,密钥加密等。
哈希算法广泛应用于很多场景,例如安全加密和数据结构中哈希表的查找,布隆过滤器和负载均衡(一致性哈希)等等。
02.常见的Hash函数
常见Hash函数有MD系列、SHA系列、MAC和CRC等。
MD系列
MD全称Message Digest,按照规范版本分为MD2、MD4、MD5三种算法,目前最常用的是MD5版本算法。
MD4算法
1990年,在MD2基础上发展出MD4算法。
MD5算法
1991年,MD4的创始人开发出MD5算法。不管多长的字符串,使用MD5计算后长度都是一样长,方便平时信息的统计和管理。
经过MD5加密生成一个固定长度为128bit的串。因为128位0和1的二进制串表达不友好,因此转化为了16进制,128/4=32位的16进制。将32位去掉前8位和后8位得到的是16位。因此会有MD5的32位和16位加密说法。
SHA系列
SHA(Security Hash Algorithm)是美国的NIST和NSA设计的一种标准的Hash算法,SHA用于数字签名的标准算法的DSS中,也是安全性很高的一种Hash算法。
SHA-1
SHA-1算法的输入消息长度小于264bit,最终输出的结果值是160 Bits,SHA-1与MD4相比较而言,主要增加了扩展变换,将前一轮的输出也加到了下一轮,这样增加了雪崩效应,而且由于其160 Bits的输出,对穷举攻击更具有抵抗性。
大致实现过程:将消息摘要转换成位字符串,对转换后的位字符串进行补位操作,附加长度值并且初始化缓存,然后计算消息摘要。
SHA-256
SHA-256算法输入报文的最大长度不超过264 Bits,输入按512 Bits分组进行处理,产生的输出是一个256 Bits的报文摘要。
SHA-2的其他衍生算法
包括SHA-224、SHA-256、SHA-384、SHA-512,这些版本共同构成了SHA大家庭。
SHA-224:SHA-256的“阉割版”,可以生成长度224bit的信息摘要。
SHA-512:可以生成长度512bit的信息摘要。
SHA-384:SHA-512的“阉割版”,可以生成长度384bit的信息摘要。
SHA家族的最新成员SHA-3已经于2015年问世。
MAC
MAC算法(Message Authentication Codes)带秘密密钥的Hash函数。
MAC算法有两种形式,分别是CBC-MAC算法和HMAC算法。在HTTP中应用最多的MAC算法是HMAC算法。
HMAC(Hash-based Message Authentication Code)算法使用Hash算法作为加密基元,HMAC结合Hash算法有多种变种,比如HMAC-SHA-1、HMAC-SHA256、HMAC-SHA512。不要误以为HMAC算法就是Hash算法加上一个密钥,HMAC算法只是基于Hash算法的,内部的实现还是相当复杂的。
CRC
CRC(Cyclic Redundancy Check):循环冗余检验。是一种根据网上数据包或计算机文件等数据产生简短固定位数校验码的一种散列函数,主要用来检测或校验数据传输或者保存后可能出现的错误。生成的数字在传输或者存储之前计算出来并且附加到数据后面,然后接收方进行检验确定数据是否发生变化。一般来说,循环冗余校验的值都是32位的整数。由于本函数易于用二进制的计算机硬件使用、容易进行数学分析并且尤其善于检测传输通道干扰引起的错误,因此获得广泛应用。
列表(Hash table,也叫哈希表)是一种查找算法,与链表、树等算法不同的是,散列表算法在查找时不需要进行一系列和关键字(关键字是数据元素中某个数据项的值,用以标识一个数据元素)的比较操作。
散列表算法希望能尽量做到不经过任何比较,通过一次存取就能得到所查找的数据元素,因而必须要在数据元素的存储位置和它的关键字(可用key表示)之间建立一个确定的对应关系,使每个关键字和散列表中一个唯一的存储位置相对应。因此在查找时,只要根据这个对应关系找到给定关键字在散列表中的位置即可。这种对应关系被称为散列函数(可用h(key)表示)。
用的构造散列函数的方法有:
(1)直接定址法:取关键字或关键字的某个线性函数值为散列地址。即:h(key)=key或h(key)=a*key+b,其中a和b为常数。
(2)数字分析法
(3)平方取值法:取关键字平方后的中间几位为散列地址。
(4)折叠法:将关键字分割成位数相同的几部分,然后取这几部分的叠加和作为散列地址。
(5)除留余数法:取关键字被某个不大于散列表表长m的数p除后所得的余数为散列地址,即:h(key)=key MOD p p≤m
(6)随机数法:选择一个随机函数,取关键字的随机函数值为它的散列地址,即:h(key)=random(key)
所以构造一个好用的散列表,最重要的是做好以下两件事情:
设计一个"好"的散列函数来计算Key值。(好的哈希函数应尽可能避免冲突的出现,而且计算时应尽可能简洁快速)
What is a block hash?
The block hash value is the DNA of a piece of data,and each block hash value is unique,random and unbreakable."Hashfun"is hello DAPP,the SK application launched by fun blockchain ecology in the gamefi stage,has a mission to implement the"interesting investment and mining"mechanism and attract millions of Genesis residents.
What is blockchain?
In essence,blockchain is a shared database of data or information stored in it.It has the characteristics of unforgeability,full trace,traceability,openness and transparency,collective maintenance,etc
边栏推荐
- Prometheus installation
- 太方便了,钉钉上就可完成代码发布审批啦!
- 记一次 .NET 某工控数据采集平台 线程数 爆高分析
- Regular replacement [JS, regular expression]
- Chrome开发工具:VMxxx文件是什么鬼
- Application practice | Shuhai supply chain construction of data center based on Apache Doris
- Qt编写物联网管理平台38-多种数据库支持
- What does the neural network Internet of things mean? Popular explanation
- Dark horse programmer - software testing - stage 08 2-linux and database-23-30-process port related, modify file permissions, obtain port number information, program and process related operations, Li
- 2022 version of stronger jsonpath compatibility and performance test (snack3, fastjson2, jayway.jsonpath)
猜你喜欢

Ziguang zhanrui completed the first 5g R17 IOT NTN satellite on the Internet of things in the world

C语言-入门-基础-语法-流程控制(七)

FS8B711S14电动红酒开瓶器单片机IC方案开发专用集成IC
Niuke Xiaobai month race 7 who is the divine Archer

Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...

Actual combat simulation │ JWT login authentication

What does the neural network Internet of things mean? Popular explanation

How is the entered query SQL statement executed?

Application practice | Shuhai supply chain construction of data center based on Apache Doris

Aiming at the "amnesia" of deep learning, scientists proposed that based on similarity weighted interleaved learning, they can board PNAS
随机推荐
公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
Oracle database, numbers Force 2 decimal places to display-Alibaba Cloud
Actual combat simulation │ JWT login authentication
Cbcgpprogressdlg progress bar used by BCG
How is the entered query SQL statement executed?
[problem] Druid reports exception SQL injection violation, part always true condition not allow solution
[QNX Hypervisor 2.2用户手册]6.3.1 工厂页和控制页
Multi table operation - external connection query
Integritee通过XCM集成至Moonriver,为其生态系统带来企业级隐私解决方案
做社交媒体营销应该注意些什么?Shopline卖家的成功秘笈在这里!
什么叫内卷?
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
Every time I look at the interface documents of my colleagues, I get confused and have a lot of problems...
What ppt writing skills does the classic "pyramid principle" teach us?
为什么最大速度是光速
记一次 .NET 某工控数据采集平台 线程数 爆高分析
Kotlin inheritance
Process of manually encrypt the mass-producing firmware and programming ESP devices
kotlin 基本数据类型
2022 Health Exhibition, health exhibition, Beijing Great Health Exhibition and health industry exhibition were held in November