Skip to content

Commit beb2d5c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 13183a0 commit beb2d5c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ciphers/md5.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
# Author: farazulhoda
22

33
# A Python program that calculates the MD5 (Message Digest 5) hash of a given string using the hashlib library.
4-
# While MD5 is considered weak and not suitable for cryptographic purposes, it can still be used for non-security-related purposes
4+
# While MD5 is considered weak and not suitable for cryptographic purposes, it can still be used for non-security-related purposes
55
# like checksums or simple data integrity checks.
66

77

8-
#By importing the hashlib library, which provides various hashing algorithms, including MD5.
8+
# By importing the hashlib library, which provides various hashing algorithms, including MD5.
99
import hashlib
1010

11+
1112
# Function to calculate the MD5 hash of a given input string.
1213
def calculate_md5_hash(input_string):
1314
# Create an MD5 hash object using hashlib.
1415
md5_hash = hashlib.md5()
1516

1617
# Update the hash object with the input string, encoded as bytes.
17-
md5_hash.update(input_string.encode('utf-8'))
18+
md5_hash.update(input_string.encode("utf-8"))
1819

1920
# Get the hexadecimal representation of the MD5 hash.
2021
md5_hash_hex = md5_hash.hexdigest()
2122

2223
# Return the MD5 hash as a hexadecimal string.
2324
return md5_hash_hex
2425

26+
2527
# Input string provided by the user.
2628
input_string = input("Enter a string: ")
2729

2830
# Calculate and print the MD5 hash.
2931
md5_hash = calculate_md5_hash(input_string)
3032
print(f"Input String: {input_string}")
31-
print(f"MD5 Hash: {md5_hash}")
33+
print(f"MD5 Hash: {md5_hash}")

0 commit comments

Comments
 (0)