md5 和 sha 加密
import hashlib
str = '123'
md5_helper = hashlib.md5()
md5_helper.update(bytes(str, 'utf-8'))
print(md5_helper.hexdigest()) # 202cb962ac59075b964b07152d234b70
sha_helper = hashlib.sha1()
sha_helper.update(bytes(str, 'utf-8'))
print(sha_helper.hexdigest()) # 40bd001563085fc35165329ea1ff5c5ecbdbbeef
加盐
import hashlib
str = '123'
md5_helper = hashlib.md5()
md5_helper.update(bytes(str, 'utf-8'))
print(md5_helper.hexdigest()) # 202cb962ac59075b964b07152d234b70
# 加盐
md5_salt_helper = hashlib.md5("salt".encode("utf8"))
md5_salt_helper.update(bytes(str, 'utf-8'))
print(md5_salt_helper.hexdigest()) # 8c4fb7bf681156b52fea93442c7dffc9
评论区