-
-
Notifications
You must be signed in to change notification settings - Fork 48.7k
Add Error Handling for Onepad Encryption/Decryption #11691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
13183a0
beb2d5c
161c237
2e05db8
1f6ef33
ebc5792
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Author: farazulhoda | ||
|
||
# A Python program that calculates the MD5 (Message Digest 5) hash of a given string using the hashlib library. | ||
Check failure on line 3 in ciphers/md5.py
|
||
# While MD5 is considered weak and not suitable for cryptographic purposes, it can still be used for non-security-related purposes | ||
Check failure on line 4 in ciphers/md5.py
|
||
# like checksums or simple data integrity checks. | ||
|
||
|
||
# By importing the hashlib library, which provides various hashing algorithms, including MD5. | ||
Check failure on line 8 in ciphers/md5.py
|
||
import hashlib | ||
|
||
|
||
# Function to calculate the MD5 hash of a given input string. | ||
def calculate_md5_hash(input_string): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide return type hint for the function: As there is no test file in this pull request nor any test function or class in the file Please provide type hint for the parameter: |
||
# Create an MD5 hash object using hashlib. | ||
md5_hash = hashlib.md5() | ||
Check failure on line 15 in ciphers/md5.py
|
||
|
||
# Update the hash object with the input string, encoded as bytes. | ||
md5_hash.update(input_string.encode("utf-8")) | ||
|
||
# Get the hexadecimal representation of the MD5 hash. | ||
md5_hash_hex = md5_hash.hexdigest() | ||
|
||
# Return the MD5 hash as a hexadecimal string. | ||
return md5_hash_hex | ||
|
||
|
||
# Input string provided by the user. | ||
input_string = input("Enter a string: ") | ||
|
||
# Calculate and print the MD5 hash. | ||
md5_hash = calculate_md5_hash(input_string) | ||
print(f"Input String: {input_string}") | ||
print(f"MD5 Hash: {md5_hash}") |
Uh oh!
There was an error while loading. Please reload this page.