Struct otpauth::totp::TOTP [] [src]

pub struct TOTP {
    pub secret: String,
}

Fields

secret: String

A secret token for the authentication

Methods

impl TOTP
[src]

fn new<S: Into<String>>(secret: S) -> TOTP

Constructs a new TOTP

fn generate(&self, period: usize, timestamp: usize) -> u32

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

fn verify(&self, code: u32, period: usize, timestamp: usize) -> bool

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

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

Generate the otpauth protocal string.

label: Label of the identifier.

issuer: The company, the organization or something else.

Trait Implementations

impl Clone for TOTP
[src]

fn clone(&self) -> TOTP

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl PartialEq for TOTP
[src]

fn eq(&self, __arg_0: &TOTP) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &TOTP) -> bool

This method tests for !=.

impl Eq for TOTP
[src]

impl Debug for TOTP
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.