[][src]Struct otpauth::TOTP

pub struct TOTP { /* fields omitted */ }

Two-step verification of TOTP algorithm

Methods

impl TOTP[src]

pub fn new<S: Into<String>>(secret: S) -> TOTP[src]

Constructs a new TOTP

pub fn from_base32<S: Into<String>>(secret: S) -> Option<TOTP>[src]

Constructs a new TOTP with base-32 encoded secret bytes

pub fn from_bytes(bytes: &[u8]) -> TOTP[src]

Constructs a new TOTP with secret bytes

pub fn generate(&self, period: u64, timestamp: u64) -> u32[src]

Generate a TOTP code.

A TOTP code is an extension of HOTP algorithm.

period: A period that a TOTP code is valid in seconds

timestamp: Create TOTP at this given timestamp

pub fn verify(&self, code: u32, period: u64, timestamp: u64) -> bool[src]

Valid a TOTP code.

code: A number that is less than 6 characters.

period: A period that a TOTP code is valid in seconds

timestamp: Validate TOTP at this given timestamp

pub fn base32_secret(&self) -> String[src]

Return the secret bytes in base32 encoding.

pub fn to_uri<S: AsRef<str>>(&self, label: S, issuer: S) -> String[src]

Generate the otpauth protocal string.

label: Label of the identifier.

issuer: The company, the organization or something else.

Trait Implementations

impl Eq for TOTP[src]

impl Clone for TOTP[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<TOTP> for TOTP[src]

impl Debug for TOTP[src]

Auto Trait Implementations

impl Unpin for TOTP

impl Sync for TOTP

impl Send for TOTP

impl UnwindSafe for TOTP

impl RefUnwindSafe for TOTP

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

impl<T, U> Into<U> for T where
    U: From<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> Borrow<T> for T where
    T: ?Sized
[src]

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

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