paseto-v1
RustCrypto based PASETO V1 implementation.
Examples
use UnsignedToken;
use ;
use RegisteredClaims;
use Duration;
// create a new keypair
let secret_key = random.unwrap;
let public_key = secret_key.public_key;
// create a set of token claims
let claims = now
.from_issuer
.for_subject;
// create and sign a new token
let signed_token = new.sign.unwrap;
// serialize the token.
let token = signed_token.to_string;
// "v1.public..."
// serialize the public key.
let key = public_key.to_string;
// "k1.public..."
use SignedToken;
use PublicKey;
use ;
// parse the token
let signed_token: = token.parse.unwrap;
// parse the key
let public_key: PublicKey = key.parse.unwrap;
// verify the token signature and validate the claims.
let validation = valid_now
.and_then
.and_then
.and_then;
let verified_token = signed_token.verify.unwrap;