Fix examples

This commit is contained in:
Jake Shadle 2019-05-15 16:20:09 +02:00
parent 6cfb5c7c0e
commit bae7a12a4b
2 changed files with 4 additions and 4 deletions

View File

@ -15,13 +15,13 @@ struct Claims {
fn main() {
let my_claims =
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
let key = "secret";
let key = b"secret";
let mut header = Header::default();
header.kid = Some("signing_key".to_owned());
header.alg = Algorithm::HS512;
let token = match encode(&header, &my_claims, key.as_ref()) {
let token = match encode(&header, &my_claims, jwt::Der::from(key)) {
Ok(t) => t,
Err(_) => panic!(), // in practice you would return the error
};

View File

@ -15,8 +15,8 @@ struct Claims {
fn main() {
let my_claims =
Claims { sub: "b@b.com".to_owned(), company: "ACME".to_owned(), exp: 10000000000 };
let key = "secret";
let token = match encode(&Header::default(), &my_claims, key.as_ref()) {
let key = b"secret";
let token = match encode(&Header::default(), &my_claims, jwt::Hmac::from(key)) {
Ok(t) => t,
Err(_) => panic!(), // in practice you would return the error
};