python的一些加密模块,hashlib,hmac,uuid

Lan
Lan
2020-05-04 / 0 评论 / 974 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2020年05月04日,已超过1453天没有更新,若内容或图片失效,请留言反馈。

md5加密:单向,算法加密后结果是一样的。

import hashlib

x = hashlib.md5()
x.update('www.lanol.cn'.encode('utf8'))
print(x.hexdigest())

image.png

ssa加密:这是一个系列,长度不同。

import hashlib

h1 = hashlib.sha1('www.lanol.cn'.encode())
print(h1.hexdigest())
h2 = hashlib.sha224('www.lanol.cn'.encode())
print(h2.hexdigest())
h3 = hashlib.sha256('www.lanol.cn'.encode())
print(h3.hexdigest())
h4 = hashlib.sha384('www.lanol.cn'.encode())
print(h4.hexdigest())
h5 = hashlib.sha512('www.lanol.cn'.encode())
print(h5.hexdigest())

image.png

一个字节占四位,如sha224

image.png

uuid1:用来生成一个全局唯一的模块

image.png

uuid3,uuid5:需要一个namespace,加密字符,生成的结果树固定的

image.png

image.png

image.png

uuid4:每次打印变化的,随机的

image.png


0

评论 (0)

取消