Python使用MD5加密算法对字符串进行加密操作示例
作者:开心果汁 时间:2021-06-23 16:30:25
本文实例讲述了Python使用MD5加密算法对字符串进行加密操作。分享给大家供大家参考,具体如下:
# encoding: utf-8
from __future__ import division
import time
import sys
reload(sys)
time1=time.time()
sys.setdefaultencoding('utf-8')
#######Md5实现方式1
import hashlib
# 创建md5对象
hl = hashlib.md5()
password="gxbdb684f1b8cfdf046744ea96d9fce48469fbac305dc6aa0d6operator_pro1520391961274j4102412y5210ying"
hl.update(password)
print (password)
sign = hl.hexdigest()
print sign
##########MD5实现方式2
import hashlib
md5=hashlib.md5(password.encode('utf-8')).hexdigest()
print(md5)
输出结果:
gxbdb684f1b8cfdf046744ea96d9fce48469fbac305dc6aa0d6operator_pro1520391961274j4102412y5210ying
856b690e42eb4ce5af4c3e5be9a97bb5
856b690e42eb4ce5af4c3e5be9a97bb5
Process finished with exit code 0
PS:关于加密解密感兴趣的朋友还可以参考本站在线工具:
文字在线加密解密工具(包含AES、DES、RC4等):
http://tools.jb51.net/password/txt_encode
MD5在线加密工具:
http://tools.jb51.net/password/CreateMD5Password
在线散列/哈希算法加密工具:
http://tools.jb51.net/password/hash_encrypt
在线MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160加密工具:
http://tools.jb51.net/password/hash_md5_sha
在线sha1/sha224/sha256/sha384/sha512加密工具:
http://tools.jb51.net/password/sha_encode
希望本文所述对大家Python程序设计有所帮助。
来源:https://blog.csdn.net/u013421629/article/details/79468420
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
情感的容器 被寄托了的QQ2010视觉设计
![](https://img.aspxhome.com/file/UploadPic/20102/3/201002-qq2010-ui-02-80s.jpg)
如何判断JavaScript变量的类型
Python爬虫防封ip的一些技巧
![](https://img.aspxhome.com/file/2023/0/76810_0s.jpg)
python使用jenkins发送企业微信通知的实现
![](https://img.aspxhome.com/file/2023/7/75917_0s.png)
RichTextBox 显示图片和word的代码
在 SQL Server 数据库开发中的十大问题
很有创意的鼠标指针风筝
![](https://img.aspxhome.com/file/UploadPic/20079/22/200792292550972s.jpg)
何在MySQL数据库中定义外键
python开发之基于thread线程搜索本地文件的方法
![](https://img.aspxhome.com/file/2023/6/65456_0s.png)
python中sys模块是做什么用的
ThinkPHP使用smarty模板引擎的方法
Python 数值区间处理_对interval 库的快速入门详解
Python数据可视化常用4大绘图库原理详解
![](https://img.aspxhome.com/file/2023/7/62297_0s.jpg)
php+jQuery实现的三 级导航栏下拉菜单显示效果
![](https://img.aspxhome.com/file/2023/1/55601_0s.jpg)
MySQL数据库在Linux下二进制日志恢复方法
Oracle学习笔记(四)
跨浏览器的本地存储(一):userData behavior
Python实现平行坐标图的两种方法小结
![](https://img.aspxhome.com/file/2023/6/61456_0s.jpg)
laravel 解决crontab不执行的问题
![](https://img.aspxhome.com/file/2023/5/75875_0s.jpg)