Md5
python
import hashlib
def generate_salt():
# 生成盐
return "random_salt_here" # 可以根据需求更改生成盐的方法
def hash_with_salt(password, salt):
# 将密码和盐连接起来并计算MD5哈希值
return hashlib.md5((password + salt).encode('utf-8')).hexdigest()
# 例子:
password = "user_password"
salt = generate_salt()
hashed_password = hash_with_salt(password, salt)
print("Salt:", salt)
print("Hashed Password:", hashed_password)