#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ------------------------------------------------------------
# 参考资料:
# python模块(转自Yuan先生) - 狂奔__蜗牛 - 博客园
# https://www.cnblogs.com/guojintao/articles/9070485.html
# ------------------------------------------------------------
# ******************** day23_4_hashlib *******************
# ******************** day23_4_hashlib *******************
# =====>>>>>>内容概览
# =====>>>>>>内容概览
# ------------------------------------------------------------
# # 1、hashlib简介
# # # 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256,
# # # SHA384, SHA512 ,MD5 算法
# # # 这个操作是单向操作,内容---->编码---->编码内容,是不可逆的,但是内容与被编码的内容的映射关系
# # # 是一一对应的
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 2、对字符串进行编码进行编码
# # # 相同的内容,编码出来的结果相同,
# ------------------------------------------------------------
# ------------------------------------------------------------
# # 2.1、对字符串进行编码进行编码
# # # 相同的内容,编码出来的结果相同
# # # 同一对象,先A后B == 直接编码AB
# ------------------------------------------------------------
# ------------------------------------------------分割线------------------------------------------------- # ------------------------------------------------分割线------------------------------------------------- # ------------------------------------------------分割线-------------------------------------------------
''' # ------------------------------------------------------------ # # 1、hashlib简介 # # # 用于加密相关的操作,3.x里代替了md5模块和sha模块,主要提供 SHA1, SHA224, SHA256, # # # SHA384, SHA512 ,MD5 算法 # # # 这个操作是单向操作,内容---->编码---->编码内容,是不可逆的,但是内容与被编码的内容的映射关系 # # # 是一一对应的 # ------------------------------------------------------------ ''' ''' # ------------------------------------------------------------ # # 2、对字符串进行编码进行编码 # # # 相同的内容,编码出来的结果相同, # ------------------------------------------------------------ ''' # # import hashlib # obj1 = hashlib.md5() # obj1.update("hello".encode("utf8")) # # obj11 = hashlib.md5() # obj11.update("hello".encode("utf8")) # # obj2 = hashlib.md5() # obj2.update("LiSir".encode("utf8")) # # print("obj1: ",obj1.hexdigest()) # print("obj11: ",obj11.hexdigest()) # print("obj2: ",obj2.hexdigest()) # # # # D:Anaconda3python.exe D:/C_cache/py/day23-re_logging_hashlib_MoKuaiDaoRu/day23_4_hashlib.py # # obj1: 5d41402abc4b2a76b9719d911017c592 # # obj11: 5d41402abc4b2a76b9719d911017c592 # # obj2: 6325936dcf78afbf43a1073ae79cde0b # # # # Process finished with exit code 0 ''' # ------------------------------------------------------------ # # 2.1、对字符串进行编码进行编码 # # # 相同的内容,编码出来的结果相同 # # # 同一对象,先A后B == 直接编码AB # ------------------------------------------------------------ ''' # # import hashlib # obj1 = hashlib.md5() # obj1.update("hello".encode("utf8")) # # obj11 = hashlib.md5() # obj11.update("hello".encode("utf8")) # # 下面的编码是在上面hello的基础上进行的 # # obj11---->编码hello---->obj11---->编码Lisir---->obj11编码结束 # # 等价:obj11---->编码helloLisir---->obj11编码结束 # obj11.update("LiSir".encode("utf8")) # # # obj2 = hashlib.md5() # obj2.update("LiSir".encode("utf8")) # # obj3 = hashlib.md5() # obj3.update("helloLiSir".encode("utf8")) # # print("obj1: ",obj1.hexdigest()) # print("obj11: ",obj11.hexdigest()) # print("obj2: ",obj2.hexdigest()) # print("obj3: ",obj3.hexdigest()) # # # D:Anaconda3python.exe D:/C_cache/py/day23-re_logging_hashlib_MoKuaiDaoRu/day23_4_hashlib.py # # obj1: 5d41402abc4b2a76b9719d911017c592 # # obj11: 84197e823a022277f1fa2dbfb5cb7990 # # obj2: 6325936dcf78afbf43a1073ae79cde0b # # obj3: 84197e823a022277f1fa2dbfb5cb7990 # # # # Process finished with exit code 0