Function oath::totp_custom_time [] [src]

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

Computes an one-time password using TOTP algorithm for arbitrary timestamp. Same as totp_raw_custom_time, 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_custom_time, HashType};

fn main () {
    // Returns TOTP result for 436437456 second after 1 Jan 1970
    totp_custom_time("0F35", 6, 0, 30, 436437456, &HashType::SHA512);
}