AES-256-GCM token encryption — interoperable with Node.js secry
Project description
secry
AES-256-GCM token encryption for Python. Zero dependencies. Tokens are fully interoperable with the Node.js secry package.
pip install secry
Usage
import secry
token = secry.encrypt("my secret", "mypassword")
text = secry.decrypt(token, "mypassword")
ok = secry.verify(token, "mypassword")
fp = secry.fingerprint("hello", "secret")
pw = secry.generate(32)
meta = secry.inspect(token)
Compact mode
Use compact=True to get shorter tokens with the sec: prefix:
token = secry.encrypt("my secret", "mypassword", compact=True)
# → sec:v2:... (shorter token)
# decrypt works the same way — prefix is detected automatically
text = secry.decrypt(token, "mypassword")
Expiry
token = secry.encrypt("temporary", "mypassword", expires="1h")
token = secry.encrypt("temporary", "mypassword", expires="30m")
token = secry.encrypt("temporary", "mypassword", expires="7d")
Token prefixes
secry:v1: AES-256-GCM (full)
secry:v2: ChaCha20-Poly1305 (full)
secry:v3: AES-256-CBC (full)
sec:v1: AES-256-GCM (compact)
sec:v2: ChaCha20-Poly1305 (compact)
sec:v3: AES-256-CBC (compact)
rwn64:v*: legacy — still accepted by decrypt/verify/inspect
Inspect
meta = secry.inspect(token)
# {
# "prefix": "secry:v2:",
# "version": "v2",
# "algo": "ChaCha20-Poly1305",
# "compact": False,
# "legacy": False,
# "kdf": "scrypt (N=16384,r=8,p=1)",
# "salt_hex": "...",
# "nonce_hex": "...",
# "payload_bytes": 64
# }
Security
- AES-256-GCM / ChaCha20-Poly1305 authenticated encryption
- scrypt key derivation (N=16384, r=8, p=1)
- Random salt + nonce per token
- Auth tag detects tampering before decryption
- Zero external dependencies
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
secry-1.1.7.tar.gz
(9.2 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
secry-1.1.7-py3-none-any.whl
(9.5 kB
view details)
File details
Details for the file secry-1.1.7.tar.gz.
File metadata
- Download URL: secry-1.1.7.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05013aebe27e59a6ace45631353364680fd2b1202846e5011e8f854f8e11ffd2
|
|
| MD5 |
69912278551bc3e4de7e317286050e18
|
|
| BLAKE2b-256 |
629a6ce9ddf3a040a3c5cf5c725cce1eca06abc588c67ff0c3a0e414d527144b
|
File details
Details for the file secry-1.1.7-py3-none-any.whl.
File metadata
- Download URL: secry-1.1.7-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0e22fe48bb042bdd79cf094aad449bbe0f56868a58ed55c89431b6c318d613
|
|
| MD5 |
3f5351566013e8a5d3e8e83d1abb5cc6
|
|
| BLAKE2b-256 |
8effdb7a1a7daf90353b748a3055aa3f5a1a16d3a56e9802ca72e7a214a8d0eb
|