扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

如何在python3中实现md5加密

扬州沐宇科技
2024-06-14 16:37:26
python3

在Python3中可以使用hashlib库来实现MD5加密。

以下是一个示例代码:

import hashlib

def md5_encrypt(text):
    md5 = hashlib.md5()
    md5.update(text.encode('utf-8'))
    return md5.hexdigest()

text = "hello world"
encrypted_text = md5_encrypt(text)
print(encrypted_text)

运行以上代码,将输出5eb63bbbe01eeed093cb22bb8f5acdc3,这就是hello world的MD5加密结果。

扫码添加客服微信