boiler-jwt

Boilerplate code for JWT token signing and decrypting.

Add to Cargo.toml

toml [dependencies] boiler-jwt = "0.1.0"

JWT Signing and Verifying Example

```rust use boilerjwt::{totoken, fromtoken, tovalue, from_value};

let appsecret = "my-secret"; let userid = 1;

// create a jwt with a BTreeMap containing an "id" field let jwt = totoken(appsecret, [ ("id".into(), tovalue(userid).unwrap()) ].into()).unwrap();

// convert back to a BTreeMap let mut claims = fromtoken(appsecret, &jwt).unwrap(); asserteq!(1, fromvalue::(claims.remove("id").unwrap()).unwrap()); ```

Password Hashing and Verifying Example

rust use boiler_jwt::{to_hash, verify}; let pass = "foo"; let hash = to_hash(pass); assert!(verify(pass, &hash)); assert!(!verify("bar", &hash));