minotp
Simple OTP library for Rust.
Usage
Installation
Add minotp into your project.
Also all hash libraries you want (e.g., SHA1 of Rust Crypto).
TOTP (commonly used)
use *;
use Sha1;
let secret = b"test";
let totp = from_bytes.unwrap;
// Get remaining seconds
let _remaining_seconds = totp.remaining_sec;
// Get token as a 6-digit owned string
let _token = totp.gen_6_str;
// -- snip -- //
Use an encoding crate to decode a Base32 encoded secret if you have to deal with one.
For example, using data_encoding.
use BASE32;
use *;
use Sha1;
let secret_base32_str = "ORSXG5A=";
let secret = BASE32.decode.unwrap;
let totp = from_bytes.unwrap;
let _token = totp.gen_6_str;
// -- snip -- //
Found any bug?
You must be kidding. Fire an issue right now if you found one!