You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
504 B
17 lines
504 B
import hashlib
|
|
import logging
|
|
|
|
# 配置日志
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def md5_encrypt(text):
|
|
# 创建一个md5哈希对象
|
|
md5_hash = hashlib.md5()
|
|
# 更新哈希对象的数据,注意这里需要将字符串转换为字节类型
|
|
md5_hash.update(text.encode('utf-8'))
|
|
# 获取十六进制表示的哈希值
|
|
encrypted_text = md5_hash.hexdigest()
|
|
|
|
return encrypted_text |