python版本坑:md5例子(python2与python3中md5区别)

对于一些字符,python2和python3的md5加密出来是不一样的.

Python2 和Python3MD5加密

# python2.7
pwd = "xxx" + chr(163) + "fj"
checkcode = hashlib.md5(pwd).hexdigest()
print checkcode # ea25a328180680aab82b2ef8c456b4ce
 
# python3.6
pwd = "xxx" + chr(163) + "fj"
checkcode = hashlib.md5(pwd.encode("utf-8")).hexdigest()
print(checkcode) # b517e074034d1913b706829a1b9d1b67

 

posted on 2018-08-01 10:07  星河赵  阅读(6790)  评论(0编辑  收藏  举报

导航