云控卡密验证客户端库 - 支持 AES+HMAC 加密通信、心跳保活、离线上报
Project description
xfcloudcard
云控卡密验证客户端库,支持 AES-256-CBC + HMAC-SHA256 加密通信、心跳保活、离线上报。
安装
pip install xfcloudcard
快速开始
方式一:上下文管理器(推荐)
from xfcloudcard import CardClient
with CardClient(server_url="http://localhost:8000", key="your-key") as client:
result = client.verify("CARD-XXXX-XXXX-XXXX-XXXX")
if result['success']:
# 业务代码写这里
pass
# 退出 with 块时自动停止心跳 + 发送离线通知
方式二:装饰器(最简洁)
from xfcloudcard import require_card
@require_card(server_url="http://localhost:8000", key="your-key")
def main():
# 仅当卡密验证通过后才执行
print("验证通过,执行业务逻辑...")
main()
方式三:命令行
# 交互模式
xfcloudcard
# 直接验证
xfcloudcard --card CARD-XXXX-XXXX-XXXX-XXXX
# 只验证,不启动心跳
xfcloudcard --card CARD-XXXX-... --once
API
CardClient(server_url, key, heartbeat_interval=60)
| 方法 | 说明 |
|---|---|
verify(card_key) |
验证卡密,成功后自动启动心跳 |
verify_only(card_key) |
只验证,不启动心跳 |
close() |
停止心跳并发送离线通知 |
is_online() |
返回心跳是否运行中 |
require_card(server_url, key, heartbeat_interval=60, exit_on_fail=True)
装饰器,在业务函数执行前自动验证卡密。
依赖
requests >= 2.25.0pycryptodome >= 3.15.0
协议
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xfcloudcard-0.1.0.tar.gz
(8.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xfcloudcard-0.1.0.tar.gz.
File metadata
- Download URL: xfcloudcard-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
564bdc0743a46b025195caee0708ce4e6e5a3099c57a2905e99c0a5804026e10
|
|
| MD5 |
d9a39c76f018c6aa6d6cada975923d3d
|
|
| BLAKE2b-256 |
de7076556e504c26463a43fe2c45c5f692f83455b7b50f636776b11f88031c30
|
File details
Details for the file xfcloudcard-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xfcloudcard-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
415b250b6a6fa5e7c1fb1911ae9dd2c8361ff3a98e1658fef9911b03e194ec1f
|
|
| MD5 |
1eef56490a90a80c2aae51a7bcb88c3e
|
|
| BLAKE2b-256 |
176eb759001a84738c76bcb5a32758c882b82ce38312b68e03a1539d187bc80b
|