Two-step verification of HOTP/TOTP for Rust.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Bump base32 crate version to 0.4 Oct 29, 2018
tests Better code coverage May 31, 2015
.gitignore First workable version May 28, 2015
.travis.yml Bump base32 crate version to 0.4 Oct 29, 2018
Cargo.toml Bump version to 0.2.7 Oct 29, 2018
LICENSE Initial commit May 28, 2015
README.md Add appveyor CI configuration file Jun 1, 2015
appveyor.yml Add appveyor CI configuration file Jun 1, 2015
rustfmt.toml Better documentation Mar 6, 2016

README.md

otpauth-rs

Build Status Build status Coverage Status Crates.io

Two-step verification of HOTP/TOTP for Rust.

Installation

Add it to your Cargo.toml:

[dependencies]
otpauth = "*"

Add extern crate otpauth to your crate root and your're good to go!

Examples

HOTP example

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

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));
}

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.