Hashing and One-Way Functions

One-Way Functions

These are functions where a certain value of X is calculated Y, but from Y it is very difficult to calculate X.


Let’s say our O.W.F (One-Way function) is the square root of a value, so y = f(27), and 27 is our X, so y = 27 * 27 → y = 729.

Now, if we want to know the value of X from the Y which is 729, we are going to need to calculate its square root, which is a much more difficult process than multiplication.


It is a function that exposed some arbitrary value, X returns a fixed-length value Y.

To better understand what a Hash is, let’s take a look at the Bad Hash function.

Bad Hash

As its name implies, this is not the type of function to be used in a production environment of your system, but it will help us understand better now.

demonstrated a sequence of characters let’s:

  • Convert all characters to their value in ASCII table
  •  Add these values
  • Return the value in module 256 (a value between 0 and 255 in hexadecimal → 0x0 – 0xFF will be obtained)

So, if we were to calculate the hash of the word “bob”, the result would be 0x33, or the word “barbara” would be 0xCB or “bill” would be 0xA3.

No matter the size of the word, a value of the same size will always be returned.

Hash can be applied for a variety of different purposes, such as a hash map that can determine where data is located in a computer’s memory, distributing data across clusters, etc.

There are many hash functions available today, each for a different type of application, when we talk about blockchain, the most interesting is the Cryptographic Hash.


Cryptographic Hash

To be classified in this category, the function must have the following properties:

Collision free

It must be nearly impossible for two different values ​​to result in the same hash.

Example: In the case of our Bad Hash function, the value “ATTACKATDAWN” results in 0x77 and the value “SIT DOWN ### MEOW” results in 0x77, so we have the scenario where two different values ​​result in the same hash.


A X value that results in a Y, X hash cannot be discovered through Y, the previously commented property about One Way Functions.


Demonstrated the Y hash, if you want to find out which element X generates the Y hash, it has to be done by trial and error (brute force), the algorithm cannot offer a shortcut.

Share on Social Media:

Leonardo Bonetti

Leonardo Bonetti

CTO of Nth and Blockchain Engineer.

"A problem solver using the right technologies to balance business with technical excellence.
Every new knowledge acquired I share with the developer community through participation in public projects on GitHub and writing articles."

What the hell does Nth mean?


1. mathematics
of or representing an unspecified ordinal number, usually the greatest in a series of values.
       the nth power.

2. informal
being the last, most recent, or most extreme of a long series.

3.idiom to the nth degree.

​       as much or as far as possible

Follow Our Social Networks

join our