python_hasp
Taiji HASP 加密锁的 Python 封装。
构建
python setup_build.py build_ext --inplace
python -m build --wheel
使用
授权信息
from taiji_hasp import TaiJiHasp
hasp = TaiJiHasp(6) # 新接口:TaiJiHasp(feature_id)
# hasp = TaiJiHasp(vendor_code, 6) # 旧接口:TaiJiHasp(vendorCode, feature_id)
print("login status =", hasp.login())
hasp.read()
print("expire date =", hasp.get_expire_date())
print("is expired =", hasp.is_expired())
print("MPC instance count =", hasp.get_mpc_instance_count())
hasp.logout()
加密 / 解密(模块级接口)
from taiji_hasp import encrypt, decrypt
feature_id = 6
plaintext = b"0123456789abcdef" # 至少 16 字节
ciphertext = encrypt(feature_id, plaintext)
restored = decrypt(feature_id, ciphertext)
assert restored == plaintext
加密 / 解密(TaiJiHasp 方法)
from taiji_hasp import TaiJiHasp
hasp = TaiJiHasp(6)
ciphertext = hasp.encrypt(b"0123456789abcdef")
plaintext = hasp.decrypt(ciphertext)
在 Cython 中调用(cimport)
将 taiji_hasp.pxd 放入 Python 环境后即可在其它 Cython 模块中 cimport:
from cython.cimports.taiji_hasp.taiji_hasp import (
hasp_encrypt_bytes,
hasp_decrypt_bytes,
check_only,
check_and_decrypt,
)
注意事项
- 数据长度必须 >= 16 字节(
HASP_MIN_BLOCK_SIZE),否则抛出ValueError;HASP 也会返回HASP_TOO_SHORT。 - 解密必须使用与加密相同的
feature_id。 - 数据为空或类型不是 bytes / bytearray / memoryview 时抛出
TypeError/ValueError。 - 登录失败、授权无效或加密 / 解密失败时抛出
RuntimeError,授权过期时错误码为-100。 encrypt/decrypt内部自带 login -> 过期检查 -> 加解密 -> logout,无需事先调用login()。
Metadata
Release files for taiji-hasp 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 127.4 MB
Release files / taiji_hasp-0.3.6-cp314-cp314-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
73b7f6c1465fc83a5138bc6f76d3f033902ca10c31ae16db8f0cd9164b4f3297
|
|
BLAKE2b-256 checksum How to use checksums |
d1322e8351b6d11d4918ba3e6c4edfcc09f1be87e4d2cfc20163916ebdcdec0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
0f14a3013482229c2fbe1ad2ca367c501a92fafd17e2aed4e30db23b1e0988dd
|
|
BLAKE2b-256 checksum How to use checksums |
b5ae57d564054ea9282c313e28a0e3a85c5db7838bab887d61f76dea3f55bee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
3f7071d05d01ae31a5fe878600d2cd5849c23e5d6c0c467dbff5119718dc888c
|
|
BLAKE2b-256 checksum How to use checksums |
eab40eeb4a23776975525731ef1eb6af890f9a9d8e29ab9075a778468fc45b04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp313-cp313-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
86cc68408831ece614d2c79980ca7e8c351de38d7332d3e676ce00b737471690
|
|
BLAKE2b-256 checksum How to use checksums |
d24955518213c9d05e7b2b2f46f3df58a4157cdd0111d0ca05b3a48a92b7eab8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2edaccfa9b89ef2731fa42c429fc1033dadc9dc440ea28d30c3c0b5cb08ff68e
|
|
BLAKE2b-256 checksum How to use checksums |
94a77d54b73c472fa3e4d4b197c881ef213a4483cd1a84d27d665c52e33fb37d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
42c38c8a4cacbcb430db012205a9cb149ed4b5ad97bdce4ef6e4c41daccc3d85
|
|
BLAKE2b-256 checksum How to use checksums |
4e131e29fe01e630135b74b180b11ebaa92da4af0c0d199a484c80ccc445640d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp312-cp312-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0927c0953bb38534eb9052f4bf3b66b293fe78d06e0244a71a0f5013ba02e02e
|
|
BLAKE2b-256 checksum How to use checksums |
39cb66f14d71bde7d8de185fc16c6763964bef763a2dffda63c1493d283155e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d5a0c00f6a2f0f8adc6d5b331df70fce7b569f2711f64c1b0cb9502ba501a142
|
|
BLAKE2b-256 checksum How to use checksums |
c4be760df0753c6db556c4d7049a7bf279c20e68df421c35343bbd76fab095e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
9ec174054a580dacb12bc21038327388823bcf673e3fc40c65216c91b5ad7133
|
|
BLAKE2b-256 checksum How to use checksums |
7717f39b4158973271794bf5952595fc346c8db75bad7214b7b5008e31a9d4b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp311-cp311-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
265d3ad4cc204635257298e2adb7440d8a02bb06f0a6de75c6c92557caf8372c
|
|
BLAKE2b-256 checksum How to use checksums |
f7982d61274d4bf2da84789c67225b7f90b9ce3af873bf402aa35cbe6c421194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
c38c8a2807f475b5af39f5974cb2894258781e6dd373faa45be467bdb723cce6
|
|
BLAKE2b-256 checksum How to use checksums |
f0b142a649482728513b370e1d13d9485b172c1eddd61f1bad4eb349604259b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
5199cdc40729ff821a900a7a80b51f0f2a63a42fb74f7de4d4aa5317a65e405d
|
|
BLAKE2b-256 checksum How to use checksums |
ac0897935e72bc7ca842892090aeb7fd9ec19f359bc1e1089dc2b9cc454d3f5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp310-cp310-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f4f1e2a8add837d6b2796243e78e73f147cb366e732ed14b430a4905d80251bb
|
|
BLAKE2b-256 checksum How to use checksums |
b33c13b7c0976371daf8396029668cf7634cd79702865d9cf52ed365452f467f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3c26d946e6b6444eb82d9c2b9c7f06f44b94b41310ecfe2a2ff97cb507815aba
|
|
BLAKE2b-256 checksum How to use checksums |
b02402480b1d5e01e8757cfae8afe0638e4ed1a3b5458e8760ca6121ac09142a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
a66a7775def1d2f6a60bead2dec3277929f194bf71b7d5b9ed02dfcd46302082
|
|
BLAKE2b-256 checksum How to use checksums |
14ecedd13d6e8a73399936fc04a1227ca8f23fb4d0a55ebc501b35d1a8f71f15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp39-cp39-win_amd64.whl
| Download URL | taiji_hasp-0.3.6-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 12.8 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
44b43f8ecefc05c1114d272dc190326bf5a202951db6a8640508230af7c439b8
|
|
BLAKE2b-256 checksum How to use checksums |
1c0133cd687d74d715e5d247aa56b077c84201759da7bc5bda37b30df390ef4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | taiji_hasp-0.3.6-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 5.1 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a14d00c2a194e48abf4c5007596ea159392f4af352e20a42ce2db0b1b40fc086
|
|
BLAKE2b-256 checksum How to use checksums |
82b5f964c7c337b211aed3320604fb6e6d9253c7f484c30bd8880ce90b2ab7a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / taiji_hasp-0.3.6-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
| Download URL | taiji_hasp-0.3.6-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
0b265c2d7342b0d4e9ef2a3530a876722a36ac3d275a03472a8daeb7540e8c13
|
|
BLAKE2b-256 checksum How to use checksums |
d7a1bdf9edfb22d8d7cc05afe9413d1b473b1bfdf9cfd4aa78afd82137d63876
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|