Secure digest functions

Savin Abeysooriya
3 min readJul 29, 2020

A message digest is a cryptographic hash function containing a string of digits created by a one-way hashing formula.A hash function may be a function that converts a numerical input value into another compressed numerical value. The input to the hash function is of arbitrary length but output is usually of fixed length. Values returned by a hash function are called message digest or just hash values.

An ideal hash function has the following properties:

  • it is very fast
  • it can return an enormous range of hash values
  • it generates a unique hash for every unique input (no collisions)
  • it generates dissimilar hash values for similar input values
  • generated hash values have no discernable pattern in their distribution

There are some popular hash function such as MD5 and SHA-1 algorithms. Lets briefly see them.

MD5

MD5 message digest algorithm is the 5th version of the Message Digest Algorithm developed by Ron Rivest to produce 128 bit message digest. MD5 is quite fast than other versions of message digest which takes the plain text of 512 bit blocks which is further divided into 16 blocks, each of 32 bit and produces the 128 bit message digest which is a set of four blocks, each of 32 bits. MD5 produces the message digest through five steps i.e. padding, append length, divide input into 512 bit blocks, initialize chaining variables a process blocks and 4 rounds, uses different constant it in each iteration.

It was developed with the main motive of security as it takes an input of any size and produces an output if a 128-bit hash value. To be considered cryptographically secure MD5 should meet two requirements:

  1. It is impossible to generate two inputs that cannot produce the same hash function.
  2. It is impossible to generate a message having the same hash value.

Initially, MD5 was developed to store one way hash of a password and some file servers also provide pre-computed MD5 checksum of a file so that the user can compare the checksum of the downloaded file to it. Most Unix based Operating Systems include MD5 checksum utilities in their distribution packages.

SHA-1

SHA means the secure hash algorithm. SHA-1 is the second edition of the Secure Hash Algorithm, with the first being SHA-0. SHA-1 or Secure Hash Algorithm 1 is a cryptographic hash function that takes an input and produces a hash value of 160 bits (20 bytes). SHA-1 is one of the key algorithms that began replacing MD5, after vulnerabilities were discovered. SHA-1 achieved widespread recognition and use. In addition, SHA-1 was known as a hashing algorithm compliant to FIPS 140.

--

--