Function oath::totp_raw_now [] [src]

pub fn totp_raw_now(
    key: &[u8],
    digits: u32,
    epoch: u64,
    time_step: u64,
    hash: &HashType
) -> u64

Computes an one-time password for this moment using TOTP algorithm. Same as totp_now, but expects key to be a &[u8].

key is a slice, that represents the shared secret;

digits - number of digits in output (usually 6 or 8);

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_raw_now, HashType};

fn main () {
    // Return value differs every 30 seconds.
    totp_raw_now(b"12345678901234567890", 6, 0, 30, &HashType::SHA1);
}