import hashlib
import os
def generate_hashed_password(password: str):
# Generate a random salt
salt = os.urandom(31).hex() # Convert to a readable hexadecimal string
# Combine the password and the salt
salted_password = password + salt
# Hash the combined password and salt using MD5
hashed_password = hashlib.md5(salted_password.encode()).hexdigest()
return salt, hashed_password
# Example usage
password = "user1234"
salt, hashed_password = generate_hashed_password(password)
print(f"Salt: {salt}")
print(f"Hashed Password: {hashed_password}")
aW1wb3J0IGhhc2hsaWIKaW1wb3J0IG9zCgpkZWYgZ2VuZXJhdGVfaGFzaGVkX3Bhc3N3b3JkKHBhc3N3b3JkOiBzdHIpOgogICAgIyBHZW5lcmF0ZSBhIHJhbmRvbSBzYWx0CiAgICBzYWx0ID0gb3MudXJhbmRvbSgzMSkuaGV4KCkgICMgQ29udmVydCB0byBhIHJlYWRhYmxlIGhleGFkZWNpbWFsIHN0cmluZwogICAgIyBDb21iaW5lIHRoZSBwYXNzd29yZCBhbmQgdGhlIHNhbHQKICAgIHNhbHRlZF9wYXNzd29yZCA9IHBhc3N3b3JkICsgc2FsdAogICAgIyBIYXNoIHRoZSBjb21iaW5lZCBwYXNzd29yZCBhbmQgc2FsdCB1c2luZyBNRDUKICAgIGhhc2hlZF9wYXNzd29yZCA9IGhhc2hsaWIubWQ1KHNhbHRlZF9wYXNzd29yZC5lbmNvZGUoKSkuaGV4ZGlnZXN0KCkKICAgIHJldHVybiBzYWx0LCBoYXNoZWRfcGFzc3dvcmQKCiMgRXhhbXBsZSB1c2FnZQpwYXNzd29yZCA9ICJ1c2VyMTIzNCIKc2FsdCwgaGFzaGVkX3Bhc3N3b3JkID0gZ2VuZXJhdGVfaGFzaGVkX3Bhc3N3b3JkKHBhc3N3b3JkKQoKcHJpbnQoZiJTYWx0OiB7c2FsdH0iKQpwcmludChmIkhhc2hlZCBQYXNzd29yZDoge2hhc2hlZF9wYXNzd29yZH0iKQo=