0
0
Cybersecurityknowledge~10 mins

Hashing algorithms (SHA, MD5) in Cybersecurity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an MD5 hash of a string in Python.

Cybersecurity
import hashlib

hash_object = hashlib.md5()
hash_object.update([1].encode())
print(hash_object.hexdigest())
Drag options to blanks, or click blank then click option'
Adigest
Bhashlib
Cencode
Dpassword123
Attempts:
3 left
💡 Hint
Common Mistakes
Using the module name instead of the string to hash.
Passing the encode method instead of calling it on the string.
2fill in blank
medium

Complete the code to create a SHA-256 hash of a string in Python.

Cybersecurity
import hashlib

hash_object = hashlib.[1]()
hash_object.update('hello world'.encode())
print(hash_object.hexdigest())
Drag options to blanks, or click blank then click option'
Asha1
Bmd5
Csha256
Dsha512
Attempts:
3 left
💡 Hint
Common Mistakes
Using MD5 instead of SHA-256.
Using uppercase letters in the function name.
3fill in blank
hard

Fix the error in the code to correctly generate an MD5 hash.

Cybersecurity
import hashlib

hash_object = hashlib.md5('data'.[1]())
print(hash_object.hexdigest())
Drag options to blanks, or click blank then click option'
Aencode
Bdecode
Chexdigest
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using decode instead of encode.
Calling hexdigest or update on the string.
4fill in blank
hard

Fill both blanks to create a SHA-1 hash of a string and print the hexadecimal digest.

Cybersecurity
import hashlib

hash_object = hashlib.[1]()
hash_object.[2]('example'.encode())
print(hash_object.hexdigest())
Drag options to blanks, or click blank then click option'
Asha1
Bupdate
Cmd5
Ddigest
Attempts:
3 left
💡 Hint
Common Mistakes
Using md5 instead of sha1.
Using digest instead of update to add data.
5fill in blank
hard

Fill all three blanks to create a SHA-512 hash of a string and print the hexadecimal digest.

Cybersecurity
import hashlib

hash_object = hashlib.[1]()
hash_object.[2]('secure'.encode())
print(hash_object.[3]())
Drag options to blanks, or click blank then click option'
Asha512
Bupdate
Chexdigest
Ddigest
Attempts:
3 left
💡 Hint
Common Mistakes
Using digest instead of hexdigest for output.
Forgetting to encode the string before updating.