加入收藏 | 设为首页 | 会员中心 | 我要投稿 莱芜站长网 (https://www.0634zz.com/)- 云连接、建站、智能边缘云、设备管理、大数据!
当前位置: 首页 > 编程开发 > Python > 正文

python学习笔记十七:base64及md5编码

发布时间:2020-07-21 09:03:13 所属栏目:Python 来源:互联网
导读:一、Python Base64编码Python中进行Base64编码和解码要用base64模块,代码示例:#-*- coding: utf-8 -*-import base64str = cnblogsstr64 = base64.b64encode(str)print str64 #Y25ibG9ncw==print base64.b64decode(str64) #cnblogs二、MD5#Python 2.ximport

str = <span style="color: #800000;">'<span style="color: #800000;">cnblogs<span style="color: #800000;">'<span style="color: #000000;">
str64 =<span style="color: #000000;"> base64.b64encode(str)
<span style="color: #0000ff;">print str64 <span style="color: #008000;">#<span style="color: #008000;">Y25ibG9ncw==
<span style="color: #0000ff;">print base64.b64decode(str64) <span style="color: #008000;">#<span style="color: #008000;">cnblogs

二、MD5

hashlib.md5(<span style="color: #008000;">#<span style="color: #008000;">Python 3.x
<span style="color: #0000ff;">import<span style="color: #000000;"> hashlib
<span style="color: #0000ff;">print(hashlib.md5(<span style="color: #800000;">"<span style="color: #800000;">whatever your string is<span style="color: #800000;">".encode(<span style="color: #800000;">'<span style="color: #800000;">utf-8<span style="color: #800000;">')).hexdigest())

(编辑:莱芜站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读