1use totp_rs::{Rfc6238, TOTP};
2
3#[cfg(feature = "otpauth")]
4fn main() {
5 let mut rfc = Rfc6238::with_defaults("totp-sercret-123".as_bytes().to_vec()).unwrap();
6
7 rfc.digits(8).unwrap();
9 rfc.issuer("issuer".to_string());
10 rfc.account_name("user-account".to_string());
11
12 let totp = TOTP::from_rfc6238(rfc).unwrap();
14 let code = totp.generate_current().unwrap();
15 println!("code: {}", code);
16}
17
18#[cfg(not(feature = "otpauth"))]
19fn main() {
20 let mut rfc = Rfc6238::with_defaults("totp-sercret-123".into()).unwrap();
21
22 rfc.digits(8).unwrap();
24
25 let totp = TOTP::from_rfc6238(rfc).unwrap();
27 let code = totp.generate_current().unwrap();
28 println!("code: {}", code);
29}