Skip to main content

Posts

Showing posts from July, 2023

SHA-1 Hash Function: What is it and How to Implement?

SHA-1 (Secure Hash Algorithm - 1) Hash functions are crucial for various security applications. SHA-1 (Secure Hash Algorithm - 1) is one of the widely used hash function. SHA-1 was developed by National Security Agency (NSA) in 1995. This function accepts an input of any size and generates hash value of 40 characters (160 bits).  Let's get started with the Step-by-Step process of generating 40 character hash value using SHA-1 hash function. Step - by - Step Process On a high level steps involved in the process of generating hash value can be summarized as below.  Message Preprocessing Initializing State Variables  Process Message Blocks Compression Function Iterate Through Blocks Final Hash Value Let's dive deeper to understand each of these steps in detail.  Message Preprocessing SHA-1 algorithm works on blocks, each one of size 512 bits. So, first thing to be done is to convert the input message to binary format and ensure that the input message (in binary format) is congruen

MD5 Hash Function: What is it and How to Implement?

MD5 (Message Digest Algorithm 5) MD5 hash function is one of the oldest and widely used hash function. MD5 stands for Message Digest Algorithm was developed in 1991 by Ronald Rivest. MD5 accepts input of any size and generates hash value of 32 characters (128 bits).  Let's get straight into Step-by-Step process of MD5 algorithm and then look into some of the vulnerabilities of MD5 Algorithm.   Step-by-Step Process On a high level below are the steps involved in generating hash value.  Padding the Input Breaking the Input into Blocks Initializing the State variables Processing the Blocks Finalizing the Hash Value Let's have a look into what does each step involve. Padding the Input MD5 Algorithm works on blocks of size 512 bits. So, first thing is to ensure the input message is of 512 bits (or multiples of 512 bits). Before processing the input message, input would be padded with the below.  '1' bit would be padded immediately after the input message. '1' bit wor