TOTP
project is used for calculate a Time-based One-time Password
For more infomation, please check the link above
git clone https://github.com/kingrongH/totp
cd totp
cargo run XW7HPZJ2L3AMPWQN
use totp::*;
fn main() -> Result<(), Box<dyn std::error::Error>>{
let x = "XW7HPZJ2L3AMPWQN";
let key = base32_to_secret(&x)?;
let totp = TOTP::default(&key);
let code = totp.get_code()?;
let left_time = totp.get_left_time();
println!("code: {:06}\r\nleft time: {}s", code, left_time);
Ok(())
}
- 2019.9.29: Change the secret type to &[u8]
under MIT LICENSE