1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Two-step verification of HOTP/TOTP.
//!
//! # Installation
//!
//! Add it to your ``Cargo.toml``:
//!
//! ```toml
//! [dependencies]
//! otpauth = "0.3"
//! ```
//!
//! # Examples
//!
//! ## HOTP example
//!
//! ```rust
//! extern crate otpauth;
//!
//! use otpauth::HOTP;
//!
//! fn main() {
//!     let auth = HOTP::new("python");
//!     let code = auth.generate(4);
//!     assert_eq!(true, auth.verify(code, 0, 100));
//! }
//! ```
//!
//! ## TOTP example
//!
//! ```rust
//! use std::time::{SystemTime, UNIX_EPOCH};
//!
//! use otpauth::TOTP;
//!
//!
//! fn main() {
//!     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));
//! }
//! ```

mod hotp;
mod totp;

pub use hotp::HOTP;
pub use totp::TOTP;