[][src]Struct itsdangerous::signer::Signer

pub struct Signer<Algorithm, DerivedKeySize, SignatureEncoder> where
    DerivedKeySize: ArrayLength<u8>, 
{ /* fields omitted */ }

This struct can sign and unsign bytes, validating the signature provided.

A salt can be used to namespace the hash, so that a signed string is only valid for a given namespace. Leaving this at the default value or re-using a salt value across different parts of your application where the same signed value in one part can mean something different in another part is a security risk.

Basic Usage

use std::time::Duration;
use itsdangerous::default_builder;

// Create a signer using the default builder, and an arbitrary secret key.
let signer = default_builder("secret key").build();

// Sign an arbitrary string.
let signed = signer.sign("hello world!");

// Unsign the string and validate whether or not its expired.
let unsigned = signer.unsign(&signed).expect("Signature was not valid");
assert_eq!(unsigned, "hello world!");

Methods

impl<Algorithm, DerivedKeySize, SignatureEncoder> Signer<Algorithm, DerivedKeySize, SignatureEncoder> where
    Algorithm: SigningAlgorithm,
    DerivedKeySize: ArrayLength<u8>,
    SignatureEncoder: Base64Sized
[src]

pub fn sign<S: AsRef<str>>(&self, value: S) -> String[src]

Signs the given string.

pub fn unsign<'a>(&'a self, value: &'a str) -> Result<&'a str, BadSignature<'a>>[src]

Unsigns the given string. The logical inverse of sign.

Remarks

This method performs zero copies or heap allocations and returns a reference to a slice of the provided value, If you need a copy, consider doing unsign(..).to_owned() to convert the &str to a String.

pub fn into_timestamp_signer(
    self
) -> TimestampSigner<Algorithm, DerivedKeySize, SignatureEncoder>
[src]

Converts this Signer into a TimestampSigner, giving it the ability to do signing with timestamps!

Auto Trait Implementations

impl<Algorithm, DerivedKeySize, SignatureEncoder> Send for Signer<Algorithm, DerivedKeySize, SignatureEncoder> where
    Algorithm: Send,
    SignatureEncoder: Send

impl<Algorithm, DerivedKeySize, SignatureEncoder> Sync for Signer<Algorithm, DerivedKeySize, SignatureEncoder> where
    Algorithm: Sync,
    SignatureEncoder: Sync

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self