码迷,mamicode.com
首页 > 编程语言 > 详细

python两种生成md5的方法

时间:2016-04-25 14:58:03      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

一. 使用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()

推荐使用第二种方法。

python两种生成md5的方法

标签:

原文地址:http://www.cnblogs.com/turingbrain/p/5430611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!