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

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

  Lan   2020-05-04 00:11   420 人阅读  0 条评论

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

本文地址: https://www.lanol.cn/post/188.html
版权声明:本文为原创文章,版权归  Lan 所有,欢迎分享本文,转载请保留出处!
赞赏 打赏二维码

文章导航

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值