Cryptographic Hash

A cryptographic hash is a mathematical algorithm that maps data of an arbitrary size to a digest of a fixed size. For example, one of the most popular hashing algorithms is the SHA-256 hashing algorithm. SHA stands for Secure Hash Algorithm. A SHA-256 hash is ALWAYS 256 bits longs, hence it is of a fixed size.

Here is a short phrase that is 10 words long:

My little dog Alfie is a very shy dog indeed.

How can we represent this phrase in 256 bits (256 bits corresponds to 64 hexidecimal characters)? By running the phrase through the SHA-256 hashing algorithm.

My little dog Alfie is a very shy dog indeed.

run through the SHA-256 hashing algoritm results in this SHA-256 hash:

a2e6267e8149b69e913c80fd5f2f896355a9583a06f59d61daa2f362bf841237

Now, let us change just one character in the phrase. We'll change the ending period to an exclamation mark:

My little dog Alfie is a very shy dog indeed!

The SHA-256 has will COMPLETELY change:

8c4888ccf520a402e727cbdb00f0c87df19704a6cfe9f1352456351048c103c0

So a cryptographic hash is an excellent way to see if data has changed, or has become corrupted.

This article was updated on November 29, 2021