All Projects → messense → otpauth-rs

messense / otpauth-rs

Licence: MIT license
Two-step verification of HOTP/TOTP for Rust.

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to otpauth-rs

KWVerificationCodeView
A customisable verification code view to capture OTPs
Stars: ✭ 83 (+207.41%)
Mutual labels:  otpauth
extract otp secret keys
Extract two-factor authentication (2FA, TFA) secret keys from export QR codes of "Google Authenticator" app
Stars: ✭ 217 (+703.7%)
Mutual labels:  otpauth
passwordless
Passwordless authentication server, supports OTP, WebAuthn, plan to implement TOTP and mobile biometric authentication
Stars: ✭ 34 (+25.93%)
Mutual labels:  otpauth
otp-authenticator-webapp
A 'Google Authenticator' like Single Page Application
Stars: ✭ 69 (+155.56%)
Mutual labels:  otpauth
DPOTPView
Customisable OTP view and Passcode view
Stars: ✭ 52 (+92.59%)
Mutual labels:  otpauth
one-wallet
1wallet - unconventional keyless, non-custodial wallet secured by Google Authenticator. EVM-compatible, smart contract operated, with composable security.
Stars: ✭ 85 (+214.81%)
Mutual labels:  otpauth

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 = "0.3"

Examples

HOTP example

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

use std::time::{SystemTime, UNIX_EPOCH};

use otpauth::TOTP;


fn main() {
    let auth = TOTP::new("python");
    let timestamp1 = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
    let code = auth.generate(30, timestamp1);
    let timestamp2 = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
    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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].