Expand description
Two-step verification of HOTP/TOTP.
§Installation
Add it to your Cargo.toml:
[dependencies]
otpauth = "0.5"§Examples
§HOTP example
use otpauth::HOTP;
let auth = HOTP::new("python");
let code = auth.generate(4);
assert_eq!(true, auth.verify(code, 0, 100));§TOTP example
use std::time::{SystemTime, UNIX_EPOCH};
use otpauth::TOTP;
let auth = TOTP::new("python");
let timestamp1 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
let code = auth.generate(30, timestamp1);
let timestamp2 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
assert_eq!(true, auth.verify(code, 30, timestamp2));