jwt4d 0.0.2
JSON Web Token library to generate, parse, sign, and verify JWTs.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
JWT4D
A JSON Web Token library to generate, parse, sign, and verify JWTs.
Currently, only the "HS256" algorithm is supported.
Example: Create a JWT
import jwt4d;
import std.datetime; // To set expiration in duration.
import std.json; // To add a custom claim value.
import std.stdio;
const string MY_SECRET = "this is a secret!";
JwtClaims claims = JwtClaims()
.issuer("my.webpage.com")
.subject("user123")
.issuedAtNow()
.expiresIn(minutes(30))
.customClaim("role", JSONValue("admin"));
string token = writeJwt(claims, MY_SECRET);
writeln(token);
Example: Read a JWT
import jwt4d;
import std.stdio;
const string MY_SECRET = "this is a secret!";
string token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTM5MjYzMjAsImlhdCI6MTc1MzkyNDUyMCwiaXNzIjoibXkud2VicGFnZS5jb20iLCJyb2xlIjoiYWRtaW4iLCJzdWIiOiJ1c2VyMTIzIn0.n5X2giJ3S5T3wrW4C0qlZrShr2ZwPiWIu6FxUzQ3K9s";
JwtClaims claims = readJwt(token, MY_SECRET);
writeln(claims.toJson());
- 0.0.2 released 31 days ago
- andrewlalis/jwt4d
- CC0
- Copyright © 2025, Andrew Lalis
- Authors:
- Dependencies:
- secured
- Versions:
-
0.0.2 2025-Jul-31 0.0.1 2025-Jul-30 ~main 2025-Jul-31 - Download Stats:
-
-
1 downloads today
-
4 downloads this week
-
17 downloads this month
-
18 downloads total
-
- Score:
- 0.3
- Short URL:
- jwt4d.dub.pm