Tag:Python hashlib
Article From:https://www.cnblogs.com/cheese320/p/9061120.html
# !/user/bin/python
# -*- coding: utf-8 -*-

import hashlib

# MD5 algorithm can be provided to prevent the inner page from being tampered with. (if the inner page is not tampered with, the value of MD5 will remain unchanged).
m = hashlib.md5()
print(m.hexdigest())  # Generate the MD5 value.
m.update(b"it's me")  # Instead of replacing hello with it's me, it is added to the back of Hello, so the MD5 value should be the same as the MD5 value of writing helloit's me directly.
m.update(b"it's been a long time since we spoken...")

m2 = hashlib.md5()
m2.update(b"helloit's me")
print(m.hexdigest())  # Why is it the same as the MD5 value of the third sentence, not the same as the MD5 value of the second sentence? TODO

s2 = hashlib.sha1
s2.update(b"helloit's me")

import hmac  # Double encryption
h = hmac.new("12345", "you are 250", encode(encoding="utf-8")) # Why not? TODO


Link of this Article: Python hashlib

Leave a Reply

Your email address will not be published. Required fields are marked *