# SHA-1, SHA-2 & SHA-256 – Know the Difference

**SHA**,” which are in different forms. In case you don’t know what it stands for or don’t have any idea about it, then you’re at the right place. Here, we’ll discuss SHA, and which are the different forms its available in and also the difference among them.

Before we get into the details of SHA, let’s first understand hash as it’s one of the essential concepts which must be clear before you try to understand what **SHA-1, SHA-2, and SHA-256** are.

Let’s understand the Hash.

## What is a Hash Algorithm?

**cryptographic functions**, a hashing algorithm is also one of the cryptographic functions that map data of any size to a fixed size of hash as an output. For example,

*“ The jay, pig, fox, zebra, and my wolves quack!“*

and once we run a specific hashing algorithm, let’s say CRC32 we get the below result:

*“ 065bf922“*

This above result “**065bf922**” is known as a hash value or hash.

Furthermore, it’s also known as one-way encryption, though it’s not always true. As said, whenever you hash any data, it gives the output as a hash value, which is of fixed length. But, that’s also the fact that different data will produce different hash values as a result. Even the smallest change to data will produce a different hash value.

Let’s look at it by making the small change from the above example:

*“ The jay, Pig, fox, zebra and my wolves quack!“*

As expected, this time result is different:

*“ 96ae0bca“*

The essential properties of the hashing algorithm are determinism. Because, no matter which computer you select, your or any other and if you compute the hash example which we used above, will give you the same result. Also, Hashing is used for many things, such as password storage, database, and many more.

**Hashing algorithms**are of different types, and all of them are used for various purposes. For example, some are used for speed, security, and others are used for optimizing certain types of data and more.

Now, let’s get into **SHA** and the difference between the different versions.

## What is SHA?

**SHA (Secure Hashing Algorithm)**is mostly for cryptographic security. Generally, whenever you share any information on the web, it breaks down into different forms. It doesn’t matter whether it’s a large file because it needs to be compressed before its shared, even written information are communicated between computers in the same manner. The system creates a shorthand of all the information you shared. For sensitive information such as passwords, a shorthand system is designed through hashing algorithms, and here SHA Hash algorithms come into the picture.

**SHA called SHA Hash Algorithms** offers a way to the computer to quickly authenticate and decrypt information shared by the users. For example, the SSL/TLS certificate used by the website we surf relies upon this SHA algorithm to quickly navigate us to the right place instead of being trapped by malicious hackers or middlemen. SHA algorithm creates a unique hash of an SSL Certificate along with its signature, which protects users like you and me from giving away private and sensitive information to cybercrooks.

Let’s learn **how does SHA works** and why it’s crucial to make use of the latest versions.

### Different Versions of SHA

**SHAs**have various forms – SHA-1, SHA-2, and SHA-256. SHA-1 is the very first iteration of the algorithm published in 1995, which was later on upgraded to an improved version compared to the first one and published in 2001 named as SHA-2. Again, if you come across SHA-256, then no need to take it differently, as “SHA-2” “SHA-256” or “SHA-256 bit,” all these names refer to the same thing. Though SHA-224 SHA-384 and SHA-512 differ due to different bitlengths of SHA-2. Furthermore, presently there are six different SHA-2 variants which are:

- SHA-224
- SHA-256
- SHA-384
- SHA-512
- SHA-512/224
- SHA-512/256

## Here’s the Role of the Hash Algorithm in SSL/TLS

**Hash functions**play an essential role in the process of creating a digital signature. Generally, signature algorithms are not capable enough to sign long messages directly without sacrificing security. So, whenever any letter is being signed, first, it’ll use a hash function on that data using a hash algorithm, which eventually reduces the size of the message into a fixed-length, to sign effectively using the signature algorithm. Likewise, the signature verification algorithm also involves hashing for verifying the hashed message, by performing certain sets of operations on that signature to verify whether it corresponds to that hash or not.

Let’s see with an example of the **RSA signature.**

Here, the signature hashes the data which has to be signed, “**encrypted**” using the signer’s private key.

**decrypts**” the signature with the help of the signer’s public key, and it compares the hash, which came as an outcome with the hash of the data on which the signature was applied. And, when it comes to SSL/TLS certificate, the data is nothing but the SSL/TLS certificate itself.

**Note:**Here, “encrypted” and “decrypted” are written in quotes because, generally, the operations used for the RSA signature algorithm aren’t the same, which are used with the RSA encryption.

## What’s the Difference Among SHA-1, SHA-2, and SHA-256?

**SHA**is an abbreviation of the

**Secure Hash Algorithm**, and other than that, SHA-2 is the updated version of the SHA-1, making it a completely different algorithm and not any variation of the original.

The significant difference between the two SHA-1 and SHA-2 is about the hash length. Here, SHA-1 is a basic version of the hashing function, and it’s close to the MD5 in nature, which means SHA-1 has a shorter code resulting in less possibility for unique combinations, whereas **SHA-2 or SHA-256** makes a more extended code and offers more complex hash.

Moreover, SHA-1, developed by the US government, offers 20 bytes (160-bit) hash values, which are represented by the hexadecimal string value of 40-digits. On the other hand, SHA-2 was also developed by the US government, especially the NSA, and it’s a family of algorithms that contains six different hash functions that provide hash/digest values of varying lengths, namely: 224, 256, 384 or 512. In other words, SHA-2 is a different range of hash functions, which includes SHA-256. Lastly, by 2015, due to vulnerability issues of SHA-1, it was phased out, and from 2016 onwards, it even became a compulsion to make use of SHA-2 for all the newly issued SSL/TLS certificates.

### Summary

**SHA-1 and SHA-256**differ from each other and what’s the role of the hashing algorithm in SSL/TLS certificates.

Moreover, it’s evident that **SHA-1** is less secured and phased out version, whereas **SHA-256** is widely used in today’s date. Also, SHA-256 is one of the variants of SHA-2 cryptographic hash functions family, which is mostly used in today’s date, including blockchain and SSL/TLS certificates.