12 releases (7 breaking)

0.8.0 Oct 17, 2023
0.7.1 May 22, 2022
0.7.0 Apr 21, 2022
0.6.1 Feb 24, 2021
0.1.1 Dec 25, 2016

#1166 in Cryptography

Download history 7851/week @ 2024-12-26 41861/week @ 2025-01-02 59419/week @ 2025-01-09 49974/week @ 2025-01-16 37776/week @ 2025-01-23 47870/week @ 2025-01-30 64711/week @ 2025-02-06 42360/week @ 2025-02-13 55448/week @ 2025-02-20 60276/week @ 2025-02-27 60027/week @ 2025-03-06 63237/week @ 2025-03-13 62934/week @ 2025-03-20 55771/week @ 2025-03-27 59430/week @ 2025-04-03 52955/week @ 2025-04-10

244,006 downloads per month
Used in 102 crates (12 directly)

MIT license

9KB
165 lines

Build Status MIT licensed Join the chat at https://gitter.im/durch/rust-jwt

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);
}

Dependencies

~3–5MB
~109K SLoC