SHA-1 Demo:

This demonstrates the padding technique used for SHA-1 and explains how SHA-1 works

Enter a message in the text box below.



Below is a bit level representation of your message.



Your message contains bits. The message will be padded to make it 448 mod 512 bits long. Since your message is we will add because: MOD 512 = We will add ONE 1 and ZEROS. After this operation a 64 bit value which represents the original length of the message is added. For this particular message the input value added will be . So the message after all appending operations are complete will look like, at the bit level the text box below. If you look at the end of message you should be able to identify the added bits.


A 160 bit buffer (4 registers) is used to hold the intermediate and final result of the hash function. They are initialized to the following values:

A = 67452301
B = EFCDAB89
C = 98BADCFE
D = 10325476
E = C3D2E1F0

At this point the message is passed in blocks of 512 bits through the the compression function as seen below:
SHA-1 compression function
Figure taken from Cryptography and Network Security: Principles and Practice by William Stallings

After all the 512 bit blocks have been processed a 160 bit message digest is produced, which is a function of all the bits of your message.

The operations of the Functions f1, f2, f3, f4 can be expressed by the following diagram:
Elementary SHA-1 Operation
Figure taken from Cryptography and Network Security: Principles and Practice by William Stallings

where t is equal to the step number and f can be expressed as:

f1 = f(t, B, C, D): (B AND C) OR (B` AND D)
f2 = f(t, B, C, D): B + C + D
f3 = f(t, B, C, D): (B AND C) OR (B AND D) OR (C AND D)
f4 = f(t, B, C, D): B + C + D

and Wt is produced according to the diagram below:
Figure taken from Cryptography and Network Security: Principles and Practice by William Stallings



This was created as part of the Cryptography Module of NSF Award No. 0113627: "Increasing Security Expertise in Aviation-oriented Computing Education: A Modular Approach", at Embry-Riddle Aeronautical University in Prescott, Arizona.

Created by Nathaniel Alderson


Project InfoModulesLinksPapersTeamNSF

Last update: August 1, 2002