Skip to main content

decode

Function decode 

Source
pub fn decode(jwt: &str, key: &str, issuer: &str) -> Result<Value, JwtError>
Expand description

Parsing and verifying jwt string, using jwt type HS256

  • jwt: jwt string
  • key: jwt hmac encrypt key
  • issuer jwt issuer value

Returns:

Ok(String): jwt string, Err(e): error

ยงExamples

let jwt_str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOi\
    JhY2NpbmZvIiwidXNlciI6ImtpdmVuIiwiZXhwIjoxNTE2MjM5MDIyfQ.t\
    dcZYbN7tavs9LdbfZT7R1SJeu75FVHvtljm8gjNGig";

let s = jwt::decode(&jwt_str, "password", "accinfo").unwrap();

assert_eq!("kiven", s["user"].as_str());