What is a hash function?
A hash function or algorithm transforms an amount of data (which can be arbitrarily large) into a fixed-length hash. Let's take a dummy hash function called “H” that takes an “x” parameter. H(“love”) could be equal to 250961 and H(“roma”) equal to 970845. Both results have the same number of digits (six), however they are remarkably different and we cannot see a correlation between the two values obtained , even using the same letters in a different order.
This function is called unidirectional, since from “love” we arrive at 250961 with a predictable computational cost, but it is basically impossible to do the opposite process (find out the information that has been hashed). An example of a function whose inverse process is easy to perform would be a function S that takes an integer and adds 25 to it; we know that, given an integer x, if the output of the function S is 35, it is because the input was the number 10.
An example of a one-way function involves multiplying arbitrarily large prime numbers. Multiplying, for example, 12,637 by 223, we get 2,818,051, this is trivial. Now try to find the two prime numbers such that when multiplied together they yield 1956803. Extremely difficult, and it is this problem that makes operations with prime numbers the basis for RSA encryption.
See, for example, the sentence below, with 18 characters (spaces are also characters):
I love Vaultree
Submitting it to SHA-256 (you can do the same in some online converter), we will get the following result:
Note that the textual output is 64 characters long and is basically a number. However, it is represented not with our decimal system, but with hexadecimal (commonly used in the field of Computer Science), which includes the digits from 0 to 9 and the letters from A to F, totaling 16 symbols — hence the name.
This same number can be represented in binary or decimal base:
9.378907345221151 * 10⁷⁶
The hash we got is nothing more than a gigantic number displayed in hexadecimal format to represent the phrase “I love Vaultree”. Now suppose we forgot to include some letter or word and we want to do it now.
I love Vaultree's SDK
This change, which in our eyes is so subtle, causes big changes in the hash that is generated, look:
It is worth mentioning that the length remains the same, as expected, but the contents have little resemblance to each other. Another characteristic of the function used to generate the hash is that it is deterministic, which means that it will produce the same result whenever the same input is used.
At Vaultree we are building an encrypted future. We love sharing valuable information and trends to help you keep your data safe. Sign up to stay in the loop and discuss the hottest trends in cybersec with a team of experts.