python實現MD5加密
阿新 • • 發佈:2019-01-09
# -*- coding: utf-8 -*-
import hashlib
def md5value(s):
md5 = hashlib.md5()
md5.update(s)
return md5.hexdigest()
#對字典中的值進行加密
def mdfive():
sign = {'phone':'18503008588','workAddress':'深圳市南山區科技中一路19號賽百諾大廈'}
for k, v in sign.items():
print(v, '->', md5value(v.encode()))
if __name__ == '__main__':
mdfive()
結果顯示:
# -*- coding: utf-8 -*-
import hashlib
def md5value(s):
md5 = hashlib.md5()
md5.update(s)
return md5.hexdigest()
#對單個值進行加密
def mdfive2():
sign = "123"
print(md5value(sign))
if __name__ == '__main__':
mdfive2()