small_jwt

Crates.iosmall_jwt
lib.rssmall_jwt
version
sourcesrc
created_at2024-12-11 12:26:05.589829
updated_at2024-12-12 11:05:18.937449
descriptionSimple and small JWT libary
homepage
repositoryhttps://gitlab.com/h45h/small_jwt
max_upload_size
id1480047
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
hash (h4-h)

documentation

README

small_jwt Pipeline Status Crates Version

Simple and small JWT library for rust.

Warning

This library is not ready for any usage. I write it for myself and if you find out that X from RFC not implemented it's okay.

Example

#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct Claims {
    pub user: String,
    pub age: u16,
    pub is_admin: bool,
}

const SECRET_KEY: &[u8] = b"my_super_secret_key";

fn main() {
    let header = small_jwt::Header::default();
    
    let claims = Claims {
        user: String::from("username"),
        age: 128,
        is_admin: true,
    };

    let token = small_jwt::encode(&header, &claims, SECRET_KEY);
    println!("enoded key: {:?}", token);

    let decoded = small_jwt::decode::<Claims>(&token.unwrap(), SECRET_KEY);
    println!("decoded payload: {:?}", decoded);
}

LICENSE

Feel free to open issues, send PR, etc.

Commit count: 18

cargo fmt