python两种生成md5的方法
一. 使用md5包
import md5 src = 'this is a md5 test.'
m1 = md5.new()
m1.update(src)
print m1.hexdigest()
二. 使用hashlib
import hashlib m2 = hashlib.md5()
m2.update(src)
print m2.hexdigest()
推荐使用第二种方法。
加密常见的问题:
1:Unicode-objects must be encoded before hashing
解决方案:import hashlib
m2 = hashlib.md5()
m2.update(src.encode('utf-8'))
print m2.hexdigest()
python两种生成md5的方法的更多相关文章
- 飘逸的python - 两种with语句实现方法
第一种是实现上下文管理器协议,即魔法方法__enter__和__exit__. class Foo: def __enter__(self): print 'in' def __exit__(self ...
- Python 两种获取文件大小的方法
import os r=os.path.getsize("/root/catbird1.stl") f=open("/root/catbird1.stl",&q ...
- 微信两种签名算法MD5和HMAC-SHA256
在做微信接口开发的过程中, 有时候发现会提示签名校验失败, 一模一样的签名逻辑就是有些接口跑步通, 找了一圈发现挺坑的; 原来是有些接口的signType签名类型有区别, 有些接口signType要求 ...
- Python_两种导入模块的方法异同
Python中有两种导入模块的方法 1:import module 2:from module import * 使用from module import *方法可以导入独立的项,也可以用from m ...
- SSH简介及两种远程登录的方法
出处 https://blog.csdn.net/li528405176/article/details/82810342 目录 SSH的安全机制 SSH的安装 启动服务器的SSH服务 SSH两种级别 ...
- C#两种创建快捷方式的方法
C#两种创建快捷方式的方法http://www.cnblogs.com/linmilove/archive/2009/06/10/1500989.html
- HTTP/HTTPS GET&POST两种方式的实现方法
关于GET及POST方式的区别请参照前面文章:http://www.cnblogs.com/hunterCecil/p/5698604.html http://www.cnblogs.com/hunt ...
- C#生成MD5的方法
///C#生成MD5的方法 public static string GetMD5(string sDataIn) { MD5CryptoServiceProvider md5 = new MD5Cr ...
- iOS - UITableView中有两种重用Cell的方法
UITableView中有两种重用Cell的方法: - (id)dequeueReusableCellWithIdentifier:(NSString *)identifier; - (id)dequ ...
随机推荐
- Python之路----------内置函数
1.abs(x)绝对值 #coding=utf-8 a = 1 b = -2 print(abs(a)) print(abs(b)) 2.all(iterable)可迭代对象里面所有内容为真返回真,空 ...
- 测试内容url
nscurl --ats-diagnostics https://xxxx/xxxx/main/ curl "https://app.api.gupiaoxianji.com/v3.8/ma ...
- leetcode 28
题目描述: Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if ...
- Dapper
前一段做一个技术分享关于dapper的,现在再总结一下,也好长时间没有更新博客了--,用到的东西 Dapper.AutoFac .AutoMapper.FluentValidation: 下面说一下D ...
- 国内固定电话正则验证:'tel': [/0\d{2,3}-\d{7,8}(|([-\u8f6c]{1}\d{1,5}))$/, "请填写有效的电话号码"],
// 验证字段 $('#info_form').validator({ rules : { checkMobile : function(ele) { return checkMobile(ele); ...
- 【转】mybatis实战教程(mybatis in action),mybatis入门到精通
MyBatis 目录(?)[-] mybatis实战教程mybatis in action之一开发环境搭建 mybatis实战教程mybatis in action之二以接口的方式编程 mybatis ...
- eclipse进行编译时总是有javascript validator错误提示
右击工程项目的properties——builders——去掉对javascript的验证就ok啦
- 论文阅读(Chenyi Chen——【ACCV2016】R-CNN for Small Object Detection)
Chenyi Chen--[ACCV2016]R-CNN for Small Object Detection 目录 作者和相关链接 方法概括 创新点和贡献 方法细节 实验结果 总结与收获点 参考文献 ...
- JAVA反射参数传递
引用:http://fish2700.blog.163.com/blog/static/130713192009103035723281/ 使用Method反射调用函数时,我们通常会遇到以下几种情况: ...
- LAMP环境搭建
安装前说明: 先安装gcc gcc-c++ make 等 可用yum install -y gcc gcc-c++ make 也可以使用rpm安装不过需要注意依赖 1.安装apache 下载链接:ht ...