Requires: OpenSSL (auto-installed via minks install jwt)
#include "jwt"
HS256 sign, verify, and decode. No libcurl dependency — only OpenSSL is needed.
| Method | Args | Out | Description |
|---|---|---|---|
JWT:Sign |
payloadJson, secret |
String | HS256-sign payload JSON → token string |
JWT:Verify |
token, secret |
Boolean | true if signature valid and exp (if present) has not passed |
JWT:Decode |
token |
String | {"header":{...},"payload":{...}} — no signature check |
JWT:Claims |
token |
String | Payload JSON only — no signature check |
JWT:Header |
token |
String | Header JSON only — no signature check |
JWT:Expired |
token |
Boolean | true if exp claim is in the past — no signature check |
Throws JWTException on a malformed token. See Object — Exception.
Var:String token;
Var:Boolean ok;
Var:String claims;
Var:Boolean expired;
JWT:Sign("{\"sub\":\"user42\",\"exp\":9999999999}", "my-secret", token);
Konsol:Print(token);
JWT:Verify(token, "my-secret", ok);
Konsol:Print("valid: ${ok}"); // valid: true
JWT:Claims(token, claims);
Konsol:Print(claims); // {"sub":"user42","exp":9999999999}
JWT:Expired(token, expired);
Konsol:Print("expired: ${expired}"); // expired: false
// Use with Curl:
Var:String response;
Curl:SetHeader("Authorization", "Bearer " + token);
Curl:Get("https://api.example.com/profile", response);
Only OpenSSL is required — libcurl is not needed. On MSYS2, OpenSSL is typically already present as a dependency of curl — check with pkg-config --exists openssl && echo found before installing.
| Platform | Command |
|---|---|
| Debian/Ubuntu | sudo apt install libssl-dev |
| Fedora/RHEL | sudo dnf install openssl-devel |
| macOS | brew install openssl |
| MSYS2 MINGW64 | pacman -S mingw-w64-x86_64-openssl |
| MSYS2 UCRT64 | pacman -S mingw-w64-ucrt-x86_64-openssl |
| MSYS2 CLANG64 | pacman -S mingw-w64-clang-x86_64-openssl |
| MSYS2 CLANGARM64 | pacman -S mingw-w64-clang-aarch64-openssl |
The Makefile auto-detects via pkg-config. For native Windows, download Win64 OpenSSL and override OPENSSL_DIR if not using the default (C:/OpenSSL-Win64):
make -C jwt_plugin OPENSSL_DIR="C:/your/openssl"