1.Python内置md5模块
1 #-*- coding:utf-8 -*- 2 3 import md5 4 5 def Str2Md5(s): 6 m=md5.new() 7 m.update(s) 8 return m.hexdigest() 9 10 if __name__=="__main__": 11 s="www.baidu.com" 12 print Str2Md5(s)
2.Python的hashlib模块
1 #-*- coding:utf-8 -*- 2 3 import hashlib 4 5 def Str2Md5(s): 6 m=hashlib.md5() 7 m.update(s) 8 return m.hexdigest() 9 10 if __name__=="__main__": 11 s="www.baidu.com" 12 print Str2Md5(s)
时间: 2024-10-03 04:29:18