A lightweight, pure Python JWT implementation
Project description
Butterfly JWT
A lightweight, pure Python JSON Web Token (JWT) library with no external dependencies.
Installation
pip install butterfly-jwt
Usage
Encoding a Token
from butterfly import jwt
# Create a token
secret_key = "your_secret_key"
payload = {"user_id": 123, "username": "example_user"}
token = jwt.encode(secret_key, payload)
Decoding a Token
from butterfly import jwt
try:
payload = jwt.decode(secret_key, token)
print(payload)
except ValueError as e:
print("Token verification failed:", str(e))
Using the ButterflyJWT Class
from butterfly.jwt import ButterflyJWT
# Create a JWT instance
jwt_handler = ButterflyJWT(secret_key)
# Create a token
token = jwt_handler.create_token(payload)
# Verify a token
payload = jwt_handler.verify_token(token)
Features
- Pure Python implementation
- No external dependencies
- URL-safe Base64 encoding
- HMAC-SHA256 signature
- Token expiration checking
- Constant-time signature verification
License
MIT License
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
butterfly_jwt-0.1.0.tar.gz
(5.3 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
File details
Details for the file butterfly_jwt-0.1.0.tar.gz.
File metadata
- Download URL: butterfly_jwt-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d14a94ce8d188e1b6b57568ce540da938b4ac87863a200ffe002d9219acfa50
|
|
| MD5 |
4979f44fc33ed4bbf84af4a78046cf8b
|
|
| BLAKE2b-256 |
16c4e8fbcb14dfd55d5735bca077935720848d77eedae6add694ca3825551f10
|
File details
Details for the file butterfly_jwt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: butterfly_jwt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcc3e0b1c4dbfad0954ea5752113089017997f42948da26e5e8e580d9e107abf
|
|
| MD5 |
805dd3c471ad791022ca4f09353f41f8
|
|
| BLAKE2b-256 |
ebc5d060c23b332d5984ef7bc7d84e5c4a6558fd0f7b9794911f0745f359cf15
|