use ovunto_security::{Algorithm, Key, TOTPGenerator}; use std::{ thread::sleep, time::{Duration, SystemTime, UNIX_EPOCH}, }; extern crate base32; extern crate ovunto_security; fn main() { let secret = [0u8; 32]; println!( "secret: {}", base32::encode(base32::Alphabet::RFC4648 { padding: false }, &secret) ); loop { for algorithm in [Algorithm::Sha1, Algorithm::Sha256, Algorithm::Sha512] { let generator = TOTPGenerator { secret: Key(secret), algorithm, ..Default::default() }; let totp = generator.generate(); println!("{algorithm}: {totp}"); } let time = SystemTime::now() .duration_since(UNIX_EPOCH) .expect("Time went backwards") .as_secs(); sleep(Duration::new(30 - time % 30, 0)); } }