您当前的位置: 首页 >  Python

彭世瑜

暂无认证

  • 0浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Python:Hashids实现ID混淆

彭世瑜 发布时间:2021-03-16 18:06:21 ,浏览量:0

文档:https://hashids.org/

Python实现: https://github.com/davidaurelio/hashids-python

安装

pip install hashids

使用示例

# -*- coding: utf-8 -*-

from hashids import Hashids

hashids = Hashids(salt='gu2kBqW38Zw=', min_length=8)

# 编码
trick_id = hashids.encode(119)
print(trick_id)  # 8BGZ7AL3

# 解码 返回的是一个元组...
real_id = hashids.decode('8BGZ7AL3')
if real_id:
    print(real_id[0])  # 119

参考 Python 反爬篇之 ID 混淆

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0558s