Skip to main content

Fast JWT

Project description

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.

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

tokenhmac-1.0.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

tokenhmac-1.0.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file tokenhmac-1.0.0.tar.gz.

File metadata

  • Download URL: tokenhmac-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tokenhmac-1.0.0.tar.gz
Algorithm Hash digest
SHA256 59dd76f2de3a6e98dad2a42d143ab21b19f4b9d779b8fcc9a6c11173edf41936
MD5 6c713c97d19b7f2764ba99575dd0aa74
BLAKE2b-256 62d027d764fb3f490135642159a8416902d1f1f451762911a78a18ce9a5dc1a4

See more details on using hashes here.

File details

Details for the file tokenhmac-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: tokenhmac-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for tokenhmac-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23d0d995d33f04cd3e6c4dc9469fdb5834aa5745e0baa294797d79d9cf09ac16
MD5 9ea3726e91aea5d5f7804e84f9fe6ec4
BLAKE2b-256 94f28dcbe5040bf503b651d4d7b5f76898c5d47746ebfb0538f05cb8411a4776

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