当前位置:网站首页>What is the development of block hash quiz game system? Hash quiz game system development (case mature)

What is the development of block hash quiz game system? Hash quiz game system development (case mature)

2022-07-04 20:36:00 VC_ MrsFu123

  01.Hash function

   One way hash function , Also known as one-way Hash function 、 Hash function , It is a function that changes the input message string of any length into a fixed output string, and it is difficult to get the input string from the output string . This output string is called the hash value of the message . Generally used to generate message summaries , Key encryption, etc .

   Hash algorithm is widely used in many scenarios , For example, secure encryption and hash table lookup in data structures , Bloom filter and load balancing ( Consistent Hashing ) wait .

  02. common Hash function

   common Hash Function has MD series 、SHA series 、MAC and CRC etc. .

  MD series

  MD Full name Message Digest, According to the Standard Version, it is divided into MD2、MD4、MD5 Three algorithms , At present, the most commonly used is MD5 Version algorithm .

  MD4 Algorithm

  1990 year , stay MD2 On the basis of the development of MD4 Algorithm .

  MD5 Algorithm

  1991 year ,MD4 Its founder developed MD5 Algorithm . No matter how long the string is , Use MD5 The calculated length is the same , It is convenient for the statistics and management of information at ordinary times .

   after MD5 Encryption generates a fixed length of 128bit String of . because 128 position 0 and 1 The binary string expression of is not friendly , So it turns into 16 Base number ,128/4=32 Bit 16 Base number . take 32 Before removing bit 8 Position and back 8 Bit gets 16 position . So there will be MD5 Of 32 Bit and 16 Bit encryption .

  SHA series

  SHA(Security Hash Algorithm) It's American NIST and NSA A standard of design Hash Algorithm ,SHA Standard algorithm for digital signature DSS in , It is also a kind of high security Hash Algorithm .

  SHA-1

  SHA-1 The input message length of the algorithm is less than 264bit, The final output value is 160 Bits,SHA-1 And MD4 By comparison , It mainly increases the extension transformation , Add the output of the previous round to the next one , This increases the avalanche effect , And because of it 160 Bits Output , More resistant to exhaustive attacks .

   The general implementation process : Convert the message digest into a bit string , Carry on the place filling operation to the converted bit string , Attach the length value and initialize the cache , Then calculate the message digest .

  SHA-256

  SHA-256 The maximum length of algorithm input message does not exceed 264 Bits, Enter the 512 Bits Work in groups , The output produced is a 256 Bits Message summary of .

  SHA-2 Other derivative algorithms of

   Include SHA-224、SHA-256、SHA-384、SHA-512, Together these versions make up SHA big family .

  SHA-224:SHA-256 Of “ Castration plate ”, Can generate length 224bit A summary of the information .

  SHA-512: Can generate length 512bit A summary of the information .

  SHA-384:SHA-512 Of “ Castration plate ”, Can generate length 384bit A summary of the information .

  SHA The newest member of the family SHA-3 Already in 2015 It came out in .

  MAC

  MAC Algorithm (Message Authentication Codes) With a secret key Hash function .

  MAC There are two forms of Algorithm , Namely CBC-MAC Algorithm and HMAC Algorithm . stay HTTP Most used in MAC The algorithm is HMAC Algorithm .

  HMAC(Hash-based Message Authentication Code) The algorithm uses Hash Algorithm as encryption primitive ,HMAC combination Hash There are many variations of the algorithm , such as HMAC-SHA-1、HMAC-SHA256、HMAC-SHA512. Don't mistake HMAC The algorithm is Hash The algorithm adds a key ,HMAC The algorithm is just based on Hash Algorithm , The internal implementation is quite complicated .

  CRC

  CRC(Cyclic Redundancy Check): Cyclic redundancy test . It is a hash function that generates a short fixed digit check code based on data packets on the Internet or computer files , It is mainly used to detect or verify the possible errors after data transmission or saving . The generated number is calculated and appended to the data before transmission or storage , The receiver then checks to see if the data has changed . Generally speaking , The values of cyclic redundancy check are 32 An integer . Because this function is easy to use binary computer hardware 、 Easy to do mathematical analysis and especially good at detecting errors caused by transmission channel interference , So it's widely used .

   list (Hash table, Also called hash table ) It's a search algorithm , With the list 、 Tree algorithm is different from , Hash table algorithm does not need to do a series of search and keyword search ( A keyword is the value of a data item in a data element , To identify a data element ) Comparison operation of .

   Hash table algorithm wants to be able to do as much as possible without any comparison , You can get the data elements you are looking for in one access , Therefore, the storage location of the data element and its keyword must be specified ( You can use key Express ) Establish a definite correspondence between , Make each keyword correspond to a unique storage location in the hash table . So in the search , Just find the position of the given keyword in the hash table according to the corresponding relationship . This correspondence is called a hash function ( You can use h(key) Express ).

   The methods used to construct hash functions are :

  (1) direct addressing : Take the key or a linear function value of the key as the hash address . namely :h(key)=key or h(key)=a*key+b, among a and b Constant .

  (2) Digital analysis

  (3) The square method : Take the middle digits after the square of the keyword as the hash address .

  (4) Folding method : Divide keywords into parts with the same number of digits , Then take the sum of these parts as the hash address .

  (5) Division and remainder : The keyword is not longer than the hash table m Number of numbers p The remainder after division is the hash address , namely :h(key)=key MOD p p≤m

  (6) Random number method : Choose a random function , Take the random function value of the keyword as its hash address , namely :h(key)=random(key)

   So construct a useful hash table , The most important thing is to do the following two things well :

   To design a " good " Hash function to calculate Key value .( A good hash function should avoid conflicts as much as possible , And the calculation should be as simple and fast as possible )

  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

原网站

版权声明
本文为[VC_ MrsFu123]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041845195304.html

随机推荐