Two-step verification of HOTP/TOTP for Rust.
Add it to your Cargo.toml
:
toml
[dependencies]
otpauth = "*"
Add extern crate otpauth
to your crate root and your're good to go!
```rust extern crate otpauth;
use otpauth::OtpAuth;
fn main() { let auth = OtpAuth::new("python"); let code = auth.hotp(4); asserteq!(true, auth.validhotp(code, 0, 100)); } ```
```rust extern crate otpauth; extern crate time;
use otpauth::OtpAuth;
fn main() { let auth = OtpAuth::new("python"); let timestamp1 = time::now().totimespec().sec as usize; let code = auth.totp(30usize, timestamp1); let timestamp2 = time::now().totimespec().sec as usize; asserteq!(true, auth.validtotp(code, 30usize, timestamp2)); } ```
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.