0
0
Cybersecurityknowledge~30 mins

Hashing algorithms (SHA, MD5) in Cybersecurity - Mini Project: Build & Apply

Choose your learning style9 modes available
Understanding Hashing Algorithms: SHA and MD5
📖 Scenario: You work in cybersecurity and need to understand how to create hash values for data using common hashing algorithms. Hashing helps verify data integrity and secure passwords.
🎯 Goal: Build a simple Python program that creates hash values of a message using MD5 and SHA-256 algorithms.
📋 What You'll Learn
Create a string variable with a specific message
Create variables for MD5 and SHA-256 hash objects
Generate hash values from the message using these objects
Display the hexadecimal hash results
💡 Why This Matters
🌍 Real World
Hashing algorithms are used in cybersecurity to verify data integrity, store passwords securely, and detect changes in files.
💼 Career
Understanding hashing is essential for roles in cybersecurity, software development, and data protection to implement secure authentication and data verification.
Progress0 / 4 steps
1
Create the message string
Create a string variable called message and set it to the exact text 'Hello, cybersecurity!'.
Cybersecurity
Need a hint?

Use single or double quotes to create the string exactly as shown.

2
Import hashlib and create hash objects
Import the hashlib module. Then create two variables: md5_hash and sha256_hash by calling hashlib.md5() and hashlib.sha256() respectively.
Cybersecurity
Need a hint?

Use import hashlib at the top. Then call hashlib.md5() and hashlib.sha256() to create the hash objects.

3
Update hash objects with the message bytes
Use the update() method on md5_hash and sha256_hash to add the bytes of message. Convert message to bytes using message.encode().
Cybersecurity
Need a hint?

Call update() on each hash object with message.encode() to convert the string to bytes.

4
Get hexadecimal digest of hashes
Create two variables: md5_result and sha256_result. Assign them the hexadecimal digest strings by calling hexdigest() on md5_hash and sha256_hash respectively.
Cybersecurity
Need a hint?

Use hexdigest() method on each hash object to get the hash as a readable hex string.