#2fa #otp

authenticator-rs

The rust implementation for google authenticator with 2fa authentication

2 unstable releases

Uses new Rust 2021

0.2.0 Dec 14, 2021
0.1.0 Dec 14, 2021

#13 in #2fa

MIT license

7KB
102 lines

authenticator-rs

The rust implementation for google authenticator with 2FA authentication

Usage

Add this to your Cargo.toml:

[dependencies]
authenticator-rs = "0.2.0"

Example

use crate::authenticator;

fn main(){
    let secret =  authenticator::create_secret(32); // create a random secret
    let pin_code_rs = authenticator::current_pin_code(secret.as_str(), 6);
    match pin_code_rs {
            Ok(code) => { println!("Current Pin Code: {}", code) }
            Err(e) => { println!("Something has error: {}", e) }
        }
}


lib.rs:

Example

use crate::authenticator;
fn main(){
    let secret =  authenticator::create_secret(32); // create a random secret
    let pin_code_rs = authenticator::current_pin_code(secret.as_str(), 6);
    match pin_code_rs {
            Ok(code) => { println!("Current Pin Code: {}", code) }
            Err(e) => { println!("Something has error: {}", e) }
        }
}

Dependencies

~5–7MB
~191K SLoC