GoogleAuthenticator
Introduction
This Rust crate can be used to interact with the Google Authenticator mobile app for 2-factor-authentication.This Rust crates can generate secrets, generate codes, validate codes and present a QR-Code for scanning the secret.It implements TOTP according to RFC6238 More about Google GoogleAuthenticator see:Wiki
Usage
Add this to your Cargo.toml
:
[]
= "0.4.0"
C/C++ lib
You can find the header file from src/authenticator.h, and then build the lib for your target.
How to make header file and build lib, you can refer to the following case.
Tools you may need: rust-lipo cbingen
## gen c/c++ header file
cbindgen ./ -l c --output src/authenticator.h
## build for MacOS and IOS
cargo lipo --features with-qrcode --targets aarch64-apple-darwin x86_64-apple-darwin aarch64-apple-ios
## build for linux musl
cargo build --all-features --lib --release --target x86_64-unknown-linux-musl
Examples
use GoogleAuthenticator;
extern crate google_authenticator;
use GA_AUTH;
Get the secret QR code
Get Google Charts Url to make QR Code
use ;
extern crate google_authenticator;
use GA_AUTH;
Get QR code image in svg format
Change Cargo.toml
to
[]
= "0.1.9"
= ["with-qrcode"]
use ;
extern crate google_authenticator;
use GA_AUTH;
Contributors
FAQ
You can post a new issue for help.