Skip to main content

Token HMAC

Like JWT but more faster as it possible.

About 4x times faster than PyJWT.

Installation

$ pip install tokenhmac

Examples

import tokenhmac

KEY = "Secret Key"

token = tokenhmac.TokenHMAC(KEY)

value = "Message"
encoded = token.encode(value.encode("utf-8"))
print(encoded)
# b'TWVzc2FnZQ==.aKA0izCttsIOAWvblvsB5xdY17DlaOzlMVeKG1f0u0o='

token.decode(encoded).decode("utf-8")
# "Message"
import tokenhmac

KEY = "Secret Key"

token = tokenhmac.TokenHMAC(KEY)

value = 123
encoded = token.encode(value.to_bytes(8, "big"))
print(encoded)
# b'AAAAAAAAAHs=.FAqptzNnojMDx_bfoH6PKTBWP7tFpo4CQyGseVUM9vA='

int.from_bytes(token.decode(encoded), "big")
# 123
import tokenhmac
import json

KEY = "Secret Key"

token = tokenhmac.TokenHMAC(KEY)

value = {"id": 123, "msg": "Message"}
encoded = token.encode(json.dumps(value).encode("utf-8"))
print(encoded)
# b'eyJpZCI6MTIzLCJtc2ciOiJNZXNzYWdlIn0=.NlnFLagfGDSn5XmSBmVnmDgqAsBApGx6GFXuvYtjPb4='

json.loads(token.decode(encoded).decode("utf-8"))
# {"id": 123, "msg": "Message"}

License

tokenhmac is offered under the MIT license.

Metadata

Release files for tokenhmac 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tokenhmac 1.0.0
File Size Uploaded Provenance Actions
tokenhmac-1.0.0.tar.gz 3.1 kB Without provenance Details for tokenhmac-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tokenhmac 1.0.0
File Interpreter ABI Platform Actions
tokenhmac-1.0.0-py3-none-any.whl Python 3 none any Details for tokenhmac-1.0.0-py3-none-any.whl

Total release size: 6.5 kB

Release files / tokenhmac-1.0.0.tar.gz

Download URL tokenhmac-1.0.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
59dd76f2de3a6e98dad2a42d143ab21b19f4b9d779b8fcc9a6c11173edf41936
BLAKE2b-256 checksum
How to use checksums
62d027d764fb3f490135642159a8416902d1f1f451762911a78a18ce9a5dc1a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Release files / tokenhmac-1.0.0-py3-none-any.whl

Download URL tokenhmac-1.0.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23d0d995d33f04cd3e6c4dc9469fdb5834aa5745e0baa294797d79d9cf09ac16
BLAKE2b-256 checksum
How to use checksums
94f28dcbe5040bf503b651d4d7b5f76898c5d47746ebfb0538f05cb8411a4776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.9.0

Security for tokenhmac 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page