jwt

JSON Web Tokens (JWT) encoder and decoder using HS256 algorithm for EZ Language

0 downloads owners: imabd645

Install

ez install jwt

Dependencies (1.0.0)

PackageRange
crypto ^1.0.0

Readme

jwt — JSON Web Tokens for EZ

Version: 1.0 Import: use "jwt" File: C:\ezlib\jwt\main.ez

Overview

The jwt library provides encoding and decoding of JSON Web Tokens (JWT) using the industry-standard HS256 (HMAC-SHA256) algorithm. It relies on the native cryptographic functions provided by crypto.


Quick Start

use "jwt"

SECRET = "my-super-secret-key-123"

# 1. Create a payload dictionary
payload = {
    "sub": "user_42",
    "role": "admin",
    "exp": clock() + 3600000  # Expires in 1 hour
}

# 2. Encode to a JWT string
token = JWT.encode(payload, SECRET)
out "Generated Token: " + token

# 3. Decode and verify the JWT string
try {
    decodedPayload = JWT.decode(token, SECRET)
    out "Decoded Subject: " + decodedPayload["sub"]
} catch e {
    out "Verification failed: " + str(e)
}

Model: JWT

JWT.encode(payload, secret)string

Generates an HS256 JWT string.

Parameters:

Returns: A standard header.payload.signature JWT string encoded in Base64Url format.


JWT.decode(token, secret)dict

Decodes a JWT and verifies its HS256 signature.

Parameters:

Returns: The decoded payload dictionary.

Throws:


Notes

Versions

VersionSizeDownloadsPublished
1.0.0 7.3 KB 0 1 hour ago

Integrity

sha256  dfde366e9f67b876ae552e738283e57e1e33ea6b0fee6f2b6f056705c330f95f