Crates.io | smpl_jwt |
lib.rs | smpl_jwt |
version | 0.8.0 |
source | src |
created_at | 2016-12-25 19:50:31.096734 |
updated_at | 2023-10-17 07:56:40.212711 |
description | Very simple JWT generation lib. |
homepage | |
repository | https://github.com/durch/rust-jwt |
max_upload_size | |
id | 7775 |
size | 13,038 |
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.
#[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);
}