Crate otpauth [−] [src]
Two-step verification of HOTP/TOTP.
Examples
HOTP
extern crate otpauth; fn main() { let auth = otpauth::OtpAuth::new("python"); let code = auth.hotp(4); assert_eq!(true, auth.valid_hotp(code, 0, 100)); }
TOTP
extern crate otpauth; extern crate time; fn main() { let auth = otpauth::OtpAuth::new("python"); let timestamp1 = time::now().to_timespec().sec as usize; let code = auth.totp(30usize, timestamp1); let timestamp2 = time::now().to_timespec().sec as usize; assert_eq!(true, auth.valid_totp(code, 30usize, timestamp2)); }
Structs
OtpAuth |