Python生成MD5的方法

一. 使用md5包

import md5

src = 'this is a source string!.'   
s = md5.new()   
s.update(src)   
print s.hexdigest()   

二. 使用hashlib

import hashlib   

s = hashlib.md5()   
s.update(src)   
print s.hexdigest()
 

推荐使用第二种方法。

你可能感兴趣的:(Python)