Function oath::hotp [] [src]

pub fn hotp(key: &str, counter: u64, digits: u32) -> Result<u64, &str>

Hi-level function, that computes an one-time password using HOTP algorithm. Same as hotp_raw, but expects key to be a &str instead.

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

counter is a counter. Due to RFC4226 it MUST be synchronized between the HOTP generator (client) and the HOTP validator (server);

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

Example

extern crate oath;

use oath::hotp;

fn main () {
    assert_eq!(hotp("ff", 23, 6).unwrap(), 330795);
}