#2fa #otp #authenticator #google #authentication

authenticator-rs

The rust implementation for google authenticator with 2fa authentication

2 unstable releases

0.2.0 Dec 14, 2021
0.1.0 Dec 14, 2021

#1928 in Cryptography

MIT license

8KB
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.5–8MB
~237K SLoC