python3

如何在python3中实现md5加密

小樊
83
2024-06-14 16:37:26
栏目: 编程语言

在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加密结果。

0
看了该问题的人还看了