网站制作学习网Python→正文:python MD5加密
字体:

python MD5加密

Python 2023/4/11 23:24:45  点击:不统计

<网f站o学a习s制p作.cn>
 python 使用引入库hashlib 实现md5加密 

如果本地不需要安装hashilib ,python自带 hashlib

PYTHON实现md5加密案例如下:

import hashlib


def md5_encode(str_code):
md5 = hashlib.md5() # 创建md5加密对象
md5.update(str_code.encode('utf-8')) # 指定需要加密的字符串
return md5.hexdigest() # 加密后的字符串
pass
if __name__ == "__main__":
code = '123456'
str_md5 = md5_encode(code)
print(code, "md5加密后", str_md5) # 结果:e10adc3949ba59abbe56e057f20f883e
print("加密后长度", len("e10adc3949ba59abbe56e057f20f883e")) # 输出长度 32

http://%77%77%77%2E%66网站制作%6F学习网%72%61%73%70%2E%63%6E

·上一篇:python for循环 >>    ·下一篇:python 实现哈希sha1加密 >>
推荐文章
最新文章