R2FA

Rust Two-Factor Authentication (R2FA) is a collection of tools for two-factor authentication.
Features
- [x] HOTP - HMAC-based One-time Password Algorithm (RFC 4226)
- [x] the key can be passed as bytes, an ASCII string, an hexadicimal string or a base32 string
- [x] customizable counter
- [x] customizable hash function (sha1, sha256, sha512)
- [x] customizable output length
- [x] customizable output alphabet
- [x] TOTP - Time-based One-time Password Algorithm (RFC 6238)
- [x] the key can be passed as bytes, an ASCII string, an hexadicimal string or a base32 string
- [x] customizable timestamp
- [x] customizable period
- [x] customizable initial time (T0)
- [x] customizable hash function (sha1, sha256, sha512)
- [x] customizable output length
- [x] customizable output alphabet
- [ ] U2F - Universal 2nd Factor (FIDO Alliance)
Installation
You can find R2FA on crates.io and include it in your Cargo.toml
:
toml
r2fa = "^0.1.0"
Quick example
More examples are available in the documentation.
```rust
extern crate r2fa;
use r2fa::otp::TOTPBuilder;
let key = "GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ".tostring();
let code = TOTPBuilder::new()
.base32key(&key)
.finalize()
.unwrap()
.generate();
assert_eq!(code.len(), 6);
```