DEV Community

Brijrajsinh parmar
Brijrajsinh parmar

Posted on

2 1

Hashing, Explain it to me like I'm 5.

Image description

As each person has its own signature, so do files.

For files, it’s called hash and it’s calculated based on the numbers of 0’s and 1’s that actually compose that file.

At the low level, each file is a bunch of zeros and ones, or bits.
Now, as a person can’t replicate exactly another person’s signature, so no two files have the same hash.

What’s more, when you change a file, its hash changes, too, because the bits contained in it change.

This is easier to understand if I show you this example:
Image description

You see that I have two strings (text) almost identical above.
I calculated the hash for the string “Hello”.

Now look what happens if I only change the first letter to lowercase (“hello”).

You see that I get two completely different values and I only changed a byte of the string (=8 bits. Each character in the string is 8 bits, aka 1 byte).

These features of a hash value allow you to make sure no changes were made to a file and it’s therefore safe.

Hope a 5-year old gets that :)

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)