Skip to main content

steam/
steam.rs

1#[cfg(feature = "steam")]
2use totp_rs::{Secret, TOTP};
3
4#[cfg(feature = "steam")]
5#[cfg(feature = "otpauth")]
6fn main() {
7    // create TOTP from base32 secret
8    let secret_b32 = Secret::Encoded(String::from("OBWGC2LOFVZXI4TJNZTS243FMNZGK5BNGEZDG"));
9    let totp_b32 = TOTP::new_steam(secret_b32.to_bytes().unwrap(), "user-account".to_string());
10
11    println!(
12        "base32 {} ; raw {}",
13        secret_b32,
14        secret_b32.to_raw().unwrap()
15    );
16    println!(
17        "code from base32:\t{}",
18        totp_b32.generate_current().unwrap()
19    );
20}
21
22#[cfg(feature = "steam")]
23#[cfg(not(feature = "otpauth"))]
24fn main() {
25    // create TOTP from base32 secret
26    let secret_b32 = Secret::Encoded(String::from("OBWGC2LOFVZXI4TJNZTS243FMNZGK5BNGEZDG"));
27    let totp_b32 = TOTP::new_steam(secret_b32.to_bytes().unwrap());
28
29    println!(
30        "base32 {} ; raw {}",
31        secret_b32,
32        secret_b32.to_raw().unwrap()
33    );
34    println!(
35        "code from base32:\t{}",
36        totp_b32.generate_current().unwrap()
37    );
38}
39
40#[cfg(not(feature = "steam"))]
41fn main() {}