Css Exp 5
Css Exp 5
Experiment no 5
Theory:
Introduction:
MD5 is a cryptographic hash function algorithm that takes the message as input of any length
and changes it into a fixed-length message of 16 bytes. MD5 algorithm stands for the
message-digest algorithm. MD5 was developed as an improvement of MD4, with advanced
security purposes. The output of MD5 (Digest size) is always 128 bits. MD5 was developed in
1991 by Ronald Rivest.
Use Of MD5 Algorithm:
● It is used for file authentication.
● In a web application, it is used for security purposes. e.g. Secure password of users etc.
● Using this algorithm, We can store our password in 128 bits format.
Algorithm:
- K = 0xEDFCBA45
- L = 0x98CBADFE
- M = 0x13DCE476
4. Process Each 512-bit Block: This is the most important step of the MD5 algorithm. Here, a
total of 64 operations are performed in 4 rounds. In the 1st round, 16 operations will be
performed, 2nd round 16 operations will be performed, 3rd round 16 operations will be
performed, and in the 4th round, 16 operations will be performed. We apply a different function
on each round i.e. for the 1st round we apply the F function, for the 2nd G function, 3rd for the H
function, and 4th for the I function.
We perform OR, AND, XOR, and NOT (basically these are logic gates) for calculating
functions. We use 3 buffers for each function i.e. K, L, M.
- F(K,L,M) = (K AND L) OR (NOT K AND M)
Now take input as initialize MD buffer i.e. J, K, L, M. Output of K will be fed in L, L will be
fed into M, and M will be fed into J. After doing this now we perform some operations to find
the output for J.
● In the first step, Outputs of K, L, and M are taken and then the function F is applied to
them. We will add modulo 232 bits for the output of this with J.
● In the second step, we add the M[i] bit message with the output of the first step.
● Then add 32 bits constant i.e. K[i] to the output of the second step.
● At last, we do left shift operation by n (can be any value of n) and addition modulo by
232.
After all steps, the result of J will be fed into K. Now the same steps will be used for all
functions G, H, and I. After performing all 64 operations we will get our message digest.
Program:
# importing the required libraries
import hashlib
# making a message
inputstring = "This is a message sent by a computer user."
# encoding the message using the library function
output = hashlib.md5(inputstring.encode())
# printing the hash function
print("Hash of the input string:")
print(output.hexdigest())
Vidya Vikas Education Trust’s
Universal College of Engineering, Kaman Road, Vasai-401208
Accredited by B+ Grade by NAAC
Output:
Conclusion:
MD5 (Message Digest Method 5) is a cryptographic hash algorithm used to generate a 128-bit
digest from a string of any length. It represents the digests as 32 digit hexadecimal numbers.
Ronald Rivest designed this algorithm in 1991 to provide the means for digital signature
verification.