This commit is contained in:
2020-01-30 21:02:25 +08:00
parent 7dac915696
commit 9b6409e134
2 changed files with 24 additions and 0 deletions

13
totp/src/main.rs Normal file
View File

@@ -0,0 +1,13 @@
extern crate otpauth;
extern crate time;
use otpauth::TOTP;
fn main() {
let auth = TOTP::new("python");
let timestamp1 = time::now().to_timespec().sec as usize;
let code = auth.generate(30, timestamp1);
let timestamp2 = time::now().to_timespec().sec as usize;
println!("code: {}", code);
assert_eq!(true, auth.verify(code, 30, timestamp2));
}