文档: 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 混淆