Skip to content
KitploitKITPLOIT
ToolsBlog
Submit
ToolsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
kit-jwt — JSON Web Token (JWT) encoding and decoding for Kit | Kitploit
Tools/GitLabGitLab/kit-lang/packages/kit-jwt
Encryption/Decryption ToolsCryptographyAuthentication
GitLabkit-lang/packages/kit-jwt

kit-jwt

JSON Web Token (JWT) encoding and decoding for Kit

View Repository
1 month agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
Share

kit-jwt

JSON Web Token (JWT) encoding and decoding for Kit


[TOC]


Files

FileDescription
.editorconfigEditor formatting configuration
.gitignoreGit ignore rules for build artifacts and dependencies
.tool-versionsasdf tool versions (Zig, Kit)
LICENSEMIT license file
README.mdThis file
examples/basic.kitBasic HS256 usage example
kit.tomlPackage manifest with metadata, capabilities, and dependencies
src/jwt.kitJWT encoding, decoding, verification, and helper API
zig/jwt_rsa.zigOpenSSL-backed RSA signing and verification bridge
zig/kit_ffi.zigKit Zig FFI value helpers used by the RSA bridge
tests/hs256.test.kitActive HS256 behavior tests
tests/types.test.kitError, type, algorithm, and claim-shape tests

Dependencies

  • Kit package dependency: crypto
  • Kit standard module: Encoding.Base64
  • Native library: OpenSSL libcrypto for RS256, RS384, and RS512 helpers
  • Capability required: ffi

The package is declared as ffi-zig because RSA signing and verification use zig/jwt_rsa.zig. HS256 uses crypto.hmac-sha256.

Installation

root@kitploit:~
kit add gitlab.com/kit-lang/packages/kit-jwt.git

Usage

root@kitploit:~
import Kit.Jwt as JWT

main = fn =>
  secret = "my-super-secret-key-at-least-32-chars"
  claims = "{\"sub\":\"user123\",\"name\":\"John Doe\",\"admin\":true,\"iat\":1700000000}"

  match JWT.encode claims secret
    | Err e ->
      println "Failed to create token:"
      println e
    | Ok token ->
      println "JWT:"
      println token

      if JWT.verify? token secret then
        println "Token is valid"
      else
        println "Token is invalid"

      match JWT.decode token secret
        | Ok decoded ->
          println "Header:"
          println decoded.header
          println "Payload:"
          println decoded.payload
        | Err e ->
          println "Decode failed:"
          println e

main

Supported signing and verification helpers:

Unsafe inspection helpers are also available for debugging tokens without verifying signatures:

  • decode-unsafe
  • get-claims-unsafe
  • get-header-unsafe

Do not use unsafe helpers for authorization decisions.

Development

Running Examples

Run the basic example with the interpreter:

root@kitploit:~
kit run examples/basic.kit --allow=ffi

Compile the example to a native binary:

root@kitploit:~
kit build examples/basic.kit --allow=ffi && ./basic

Running Tests

Run the active test suite:

root@kitploit:~
kit test --allow=ffi

Run the active test suite with coverage:

root@kitploit:~
kit test --coverage --allow=ffi

Run the optional RSA test files directly:

root@kitploit:~
kit test tests/rs256.kit.disabled --allow=ffi
kit test tests/rs384.kit.disabled --allow=ffi
kit test tests/rs512.kit.disabled --allow=ffi

Running kit dev

Run the standard development workflow (format, check, test):

root@kitploit:~
kit dev

This will:

  1. Check formatting for Kit source and example files
  2. Type check source and examples
  3. Run active tests with coverage

Running Parity

Run interpreter/compiler parity checks for examples:

root@kitploit:~
kit parity --failures-only

Parity checks that examples run through the interpreter, compile successfully, execute successfully, and produce matching output.

Generating Documentation

Generate API documentation from doc comments:

root@kitploit:~
kit doc src/jwt.kit

Note: Kit sources with doc comments (##) generate HTML documentation.

Cleaning Build Artifacts

Remove generated files, caches, and build artifacts:

root@kitploit:~
kit task clean

Note: Defined in kit.toml.

Local Installation

To install this package locally for development:

root@kitploit:~
kit install

This installs the package to ~/.kit/packages/@kit/jwt/, making it available for import as Kit.Jwt in other projects.

Security Notes

  • Use strong, random HS256 secrets. A minimum of 256 bits is recommended.
  • Never commit private keys or production JWT secrets.
  • Validate application claims such as exp, nbf, iat, iss, and aud after decoding.
  • Prefer short-lived tokens and rotate keys according to your application's threat model.
  • Use HTTPS whenever transmitting JWTs over a network.

License

This package is released under the MIT License - see LICENSE for details.

Download Tool
tests/rs256.kit.disabledOptional RS256 behavior tests
tests/rs384.kit.disabledOptional RS384 behavior tests
tests/rs512.kit.disabledOptional RS512 behavior tests
AlgorithmHelpers
HS256encode, encode-with-header, decode, verify?
RS256encode-rs256, decode-rs256, verify-rs256?, get-claims-rs256
RS384encode-rs384, decode-rs384, verify-rs384?, get-claims-rs384
RS512encode-rs512, decode-rs512, verify-rs512?, get-claims-rs512