ComputersProgramming

Hash function: what is it, what is needed and what happens

Often when downloading torrents or directly the files themselves in the description is something like "ad33e486d0578a892b8vbd8b19e28754" (for example, in ex.ua), often with a postscript "md5". This hash code is the result that the hash function produces after processing the incoming data. In a translation from English, the hash means confusion, marijuana, grass or a dish of finely chopped meat and vegetables. It is very difficult to decipher the hash, we can say that it is almost impossible. Then the question arises: "Why do all these hash functions at all , if they give out an incomprehensible abracadabra, which still does not lend itself to deciphering?" This will be discussed in this article.

What is a hash function and how does it work?

This function is designed to convert incoming data of an arbitrarily large size into a fixed length result. The process of such a conversion is called hashing, and the result is a hash or hash code. Sometimes the words "imprint" or "message digest" are used, but in practice they are much less common. There are many different algorithms of how you can turn any array of data into a certain sequence of characters of a certain length. The most widely used algorithm was md5, which was developed back in 1991. Despite the fact that to date md5 is somewhat outdated and is not recommended for use, it is still still in the works and often instead of the word "hash code", the sites just write md5 and indicate the code itself.

Why do I need a hash function?

Knowing the result, it is almost impossible to determine the initial data, but the same incoming data gives the same total. Therefore, a hash function (also known as convolution function) is often used to store very important information, such as a password, login, ID number and other personal information. Instead of comparing the information entered by the user with those stored in the database, their hashes are compared. This gives a guarantee that with an occasional leak of information, no one can use important data for their purposes. By comparing the hash code, it is also convenient to check the correctness of downloading files from the Internet, especially if communications failures occurred during the download.

Hash functions: what they are like

Depending on its purpose, the hash function can be one of three types:

1. Function for checking the integrity of information

When data is transmitted over the network, the hash of the packet is calculated, and this result is also transmitted along with the file. Upon receipt, the hash code is computed again and compared with the value obtained over the network. If the code does not match, then it indicates errors, and the corrupted package will be transferred again. Such a function has a fast calculation speed, but a small number of hash values and poor stability. An example of this type: CRC32, which has only 232 differing values.

2. Cryptographic function

This type is used to protect against unauthorized access (ND). They allow you to check if the data corruption occurred as a result of ND during the transfer of files over the network. The true hash is publicly available in this case, and the hash of the received file can be calculated using many different programs. Such functions have a long and stable working life, and the search for collisions (possible coincidences of the result from different initial data) is very complicated. It is these functions that are used to store passwords in the database (SH1, SH2, MD5) and other valuable information.

3. A function designed to create an effective data structure

Its goal is a compact and fairly orderly organization of information in a special structure, which is called a hash table. Such a table allows you to add new information, delete information and search for the right data at a very high speed.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.delachieve.com. Theme powered by WordPress.