Skip to main content

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


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.6.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secry-1.1.6-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file secry-1.1.6.tar.gz.

File metadata

  • Download URL: secry-1.1.6.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for secry-1.1.6.tar.gz
Algorithm Hash digest
SHA256 0df8943d27b027c1075ad356d591496164db00b337827ce38f412bdf92a39605
MD5 40ba97453507ad4f89e2c9796beb5c89
BLAKE2b-256 d378de20e31835effc62b7dd6b63ab5fc17d8ba08c206dab3841d7d605f945b9

See more details on using hashes here.

File details

Details for the file secry-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: secry-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for secry-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 df057fe8d5ffd214eb9027c12219930c7e1097efdcb0d9c5972bc27f51bb90d7
MD5 3395a48cd1c0f983eff81c4b87f97101
BLAKE2b-256 13f067a8086b80cc711e2776259de6f21a045908beccd7e659bc82bf5b083a89

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page