本文實(shí)例講述了Python使用MD5加密算法對字符串進(jìn)行加密操作。分享給大家供大家參考,具體如下:
# encoding: utf-8from __future__ import divisionimport timeimport sysreload(sys)time1=time.time()sys.setdefaultencoding('utf-8')#######Md5實(shí)現(xiàn)方式1import hashlib# 創(chuàng)建md5對象hl = hashlib.md5()password="gxbdb684f1b8cfdf046744ea96d9fce48469fbac305dc6aa0d6operator_pro1520391961274j4102412y5210ying"hl.update(password)print (password)sign = hl.hexdigest()print sign##########MD5實(shí)現(xiàn)方式2import hashlibmd5=hashlib.md5(password.encode('utf-8')).hexdigest()print(md5)輸出結(jié)果:
gxbdb684f1b8cfdf046744ea96d9fce48469fbac305dc6aa0d6operator_pro1520391961274j4102412y5210ying
856b690e42eb4ce5af4c3e5be9a97bb5
856b690e42eb4ce5af4c3e5be9a97bb5
Process finished with exit code 0
希望本文所述對大家Python程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選