Skip to content

签名 验签 加密

一、签名

1.1 MD5

python
import hashlib

def md5_hash(text):
    # 创建一个md5 hash对象
    md5 = hashlib.md5()
    # 向hash对象提供要哈希的数据,这里使用encode()将字符串转换为字节
    md5.update(text.encode('utf-8'))
    # 获取16进制的哈希结果
    result = md5.hexdigest()
    return result

# 使用示例
text = "Hello, World!"
hashed_text = md5_hash(text)
print(hashed_text)  # 输出: 65a8e27d8879283831b664bd8b7f0ad4