Function oath::totp_now [] [src]

pub fn totp_now<'a>(
    key: &str,
    digits: u32,
    epoch: u64,
    time_step: u64,
    hash: &HashType
) -> Result<u64, &'a str>

Computes an one-time password for current moment of time using TOTP algorithm. Same as totp_raw_now, but expects key to be a &str and returns Result.

key is a string slice, that represents the shared secret;

digits - number of digits in output;

epoch - initial counter time T0 (default value is 0)

time_step - time step in seconds (default value is 30)

Example

extern crate oath;

use oath::{totp_now, HashType};

fn main () {
    // Return value differs every 30 seconds.
    totp_now("0F35", 6, 0, 30, &HashType::SHA512);
}