Experiment-2.
Student Name: Akashdeep Singh                                         UID: 24MCS10003
Branch: ME-CSE                                                        Section/Group: 24MCS1/A
Semester: 2                                                           Date of Performance: 20/03/2025
Subject: Information Security                                         Subject Code: 24CSH-662
1.   Aim: Calculate the message digest of a text using the MD5 algorithm.
2.   Task to be done:
         •   Understand the concept of cryptographic hash functions and message digests.
         •   Learn about the MD5 algorithm and its characteristics.
         •   Implement MD5 hashing for a given text input.
         •   Display and verify the generated hash value.
3.   Software Required: Online Python Compiler
4.   Description:
     A message digest is a fixed-size output generated from an arbitrary length input, ensuring data integrity
     during transmission or storage.
     MD5 is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value, typically
     represented as a 32-character hexadecimal number. It is fast and commonly used for file verification and
     checksums, though it is not recommended for security-critical applications due to vulnerabilities.
5.   Algorithm:
         •   Take a text input from the user or define a fixed text.
         •   Encode the text into bytes, since the MD5 algorithm works on byte sequences.
         •   Apply the MD5 hashing algorithm to the encoded text.
         •   Generate the hexadecimal representation of the resulting hash.
         •   Display the original text and its corresponding MD5 message digest.
6.   Code And Output:
        import hashlib
        # Input text
Akashdeep Singh                                                                                  24MCS10003
       text = "Hello, welcome to MD5 hashing!"
       # Encoding the text to bytes
       encoded_text = text.encode()
       # Creating MD5 hash object
       md5_hash = hashlib.md5(encoded_text)
       # Getting the hexadecimal digest
       digest = md5_hash.hexdigest()
       # Displaying the message digest
       print("Original Text:", text)
       print("MD5 Message Digest:", digest)
7.   Learning Outcomes:
       •   Understood the role and functioning of cryptographic hash functions.
       •   Learned the features and limitations of the MD5 algorithm.
       •   Gained practical experience in implementing MD5 hashing using Python.
       •   Developed skills to generate and interpret message digests for data verification.
       •   Recognized the importance of data integrity and the effect of input changes on hash outputs.
Akashdeep Singh                                                                                24MCS10003