smpl_jwt

Crates.iosmpl_jwt
lib.rssmpl_jwt
version0.9.0
created_at2016-12-25 19:50:31.096734+00
updated_at2025-12-09 22:02:37.661211+00
descriptionVery simple JWT generation lib.
homepage
repositoryhttps://github.com/durch/rust-jwt
max_upload_size
id7775
size18,814
Drazen Urch (durch)

documentation

https://durch.github.io/rust-jwt

README

MIT licensed

rust-jwt [docs]

Very simple JWT generation lib, provides a Jwt struct which can be finalised to produce an encoded and signed String representation.

Generic over serde::ser::Serialize trait.

Usage

#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate smpl_jwt;

use serde::Serialize;
use smpl_jwt::{Jwt, RSAKey};

fn main() {
  #[derive(Serialize)]
  struct ExampleStruct {
    field: String
  }

  let rsa_key = match RSAKey::from_pem("random_rsa_for_testing") {
    Ok(x) => x,
    Err(e) => panic!("{}", e)
  };

  let jwt = Jwt::new(ExampleStruct{field: String::from("test")},
                    rsa_key,
                    None);
  println!("{}", jwt);
}
Commit count: 37

cargo fmt