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 :)

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs