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 50 51 52 53 54 55
//! Two-step verification of HOTP/TOTP.
//!
//! # Installation
//!
//! Add it to your ``Cargo.toml``:
//!
//! ```toml
//! [dependencies]
//! otpauth = "0.2"
//! ```
//!
//! Add ``extern crate otpauth`` to your crate root and your're good to go!
//!
//! # 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
//! 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;
//! assert_eq!(true, auth.verify(code, 30, timestamp2));
//! }
//! ```
extern crate crypto;
extern crate byteorder;
extern crate base32;
pub mod hotp;
pub mod totp;
pub use hotp::HOTP;
pub use totp::TOTP;