The main difference between MD5 and SHA is that MD5 is not cryptographically stronger and not secure while SHA is more cryptographically stronger and secure with versions such as SHA 256 and SHA 512.
There are various algorithms used to protect the messages in communication. Two of them are MD5 and SHA. Herein, the MD5 is considered as cryptographically broken and cause collisions. On the other hand, SHA refers to a family of cryptographic hash functions developed by the National Institute of Standards and Technology (NIST). Overall, SHA has versions such as SHA 256 and SHA 512, which are more secure than MD5.
Key Areas Covered
Cryptography, MD5, SHA
What is MD5
MD5 stands for Message-Digest Algorithm. It is capable of producing a 128-bit hash value. The initial motivation for designing this algorithm was to use is as a cryptographic hash function. However, it caused much vulnerability. But, it is possible to use it as a checksum to verify data integrity. Moreover, it is suitable for non-cryptographic tasks such as finding the partition for a specific key in a partitioned database.
Generally, a cryptographic hash function has to be capable of finding two separate messages that hash to the same value. MD5 fails in achieving this requirement. Furthermore, file servers provide previously computed MD5 checksum for the files. Also, it allows the user to compare the checksum of the downloaded file to it. Considering examples of applications that use MD5, Unix based OS contains MD5 sum utilities in their distribution packages.
What is SHA
SHA stands for Secure Hash Algorithm. National Institute of Standard and Technology published various versions of SHA. Some of them are as follows.
SHA-0: It is an original version of the 160-bit hash function. Later, SHA -1 replaced it.
SHA-1: It is a 160-bit hash function. It was designed as a part of the Digital Signature Algorithm. However, after 2010, it was not in use.
SHA-2: It consists of two equivalent hash functions with different block sizes. They are SHA 256 and SHA 512. SHA-256 uses 32-bit words, while SHA-523 uses 64-bit words. Moreover, there are truncated versions called SHA-224, SHA-384, SHA-512/224 and SHA 512/256.
SHA-3: Internal structure of SHA-2 is different from the rest of the SHA family. Additionally, it supports the same hash lengths as SHA-2.
Difference Between MD5 and SHA
MD5 is a widely used algorithm that uses a hash function producing a 128-bit hash value. In contrast, SHA is a set of cryptographic hash functions published by the National Institute of Standards and Technology (NIST) as a U.S. Federal Information Processing Standard (FIPS).
Moreover, MD5 stands for Message-Digest Algorithm while SHA stands for Secure Hash Algorithm.
An important difference between MD5 and SHA is that the SHA is more secure than MD5.
Also, another difference between MD5 and SHA is that MD5 is faster than SHA.
Moreover, many attacks have been reported on MD5, whereas there are not many attacks reported on SHA. Hence, this is another difference between MD5 and SHA.
In brief, MD5 and SHA are two algorithms that help to secure the messages in communication. However, the main difference between MD5 and SHA is that MD5 is not cryptographically stronger and not secure while SHA is more cryptographically stronger and secure with versions such as SHA 256 and SHA 512.