Close

2022-04-22

What is SHA? What is SHA used for?

cryptography

SHA stands for secure hashing algorithm. SHA is a modified version of MD5 and is used for hashing data and certificates. A hashing algorithm shortens the input data into a more diminutive form that cannot be understood using bitwise operations, modular additions, and compression functions. You may be wondering, can hashing be cracked or decrypted? Hashing is similar to encryption; the only difference between hashing and encryption is that hashing is one-way, meaning once the data is hashed, the resulting hash digest cannot be cracked unless a brute force attack is used. See the image below for the working of the SHA algorithm. SHA works in such a way that even if a single character of the message changes, it will generate a different hash. For example, hashing of two similar but different messages, i.e., Heaven and Heaven, is different. However, there is only a difference between capital and small letter.

The initial message is hashed with SHA-1, resulting in the hash digest “06b73bd57b3b938786daed820cb9fa4561bf0e8e”. If the second, similar message is hashed with SHA-1, the hash digest will look like “66da9f3b8d9d83f34770a14c38276a69433a535b”. This is referred to as the avalanche effect. This effect is significant in cryptography, as even the slightest change in the input message completely changes the output. This will stop attackers from understanding what the hash digest initially said and tell the receiver of the message whether or not the message has been changed while in transit.

SHAs also assist in revealing if an original message was changed in any way. By referencing the original hash digest, a user can tell if even a single letter has been changed, as the hash digests will be completely different. One of the most essential parts of SHAs is that they are deterministic. Once the hash function is known, any computer or user can recreate the hash digest. The determinism of SHAs is one of the reasons every SSL certificate on the Internet must have been hashed with a SHA-2 function.

Different SHA Forms

When learning about SHA forms, several different types of SHA are referenced. SHA names are SHA-1, SHA-2, SHA-256, SHA-512, SHA-224, and SHA-384, but in actuality, there are only two types: SHA-1 and SHA-2. The other more significant numbers, like SHA-256, are just versions of SHA-2 that note the bit lengths of the SHA-2. SHA-1 was the original secure hashing algorithm, returning a 160-bit hash digest after hashing. Someone may wonder, can SHA-2 be cracked like SHA-1? The answer is yes. Due to the short length of the hash digest, SHA-1 is more easily brute-forced than SHA-2, but SHA-2 can still be brute-forced. Another issue of SHA-1 is that it can give the same hash digest to two different values, as the number of combinations that can be created with 160 bits is tiny. SHA-2, on the other hand, gives every digest a unique value, which is why all certificates are required to use SHA-2.

SHA-2 can produce a variety of bit-lengths, from 256 to 512 bits, allowing it to assign unique values to every hash digest created. Collisions occur when two values have the same hash digest. SHA-1 can easily create collisions, making it easier for attackers to get two matching digests and recreate the original plaintext. Compared to SHA-1, SHA-2 is much more secure and has been required in all digital signatures and certificates since 2016. Common attacks like brute force attacks can take years or even decades to crack the hash digest, so SHA-2 is considered the most secure hash algorithm.

The full article is on What is SHA, and What is SHA used for?