avanza-rs 0.1.3

A Rust API client for Avanza
Documentation
1
2
3
4
5
6
7
8
9
use otpauth::TOTP;
use std::time::{SystemTime, UNIX_EPOCH};

pub(crate) fn generate_totp(secret: &str) -> u32 {
    let auth = TOTP::from_base32(secret).unwrap();
    let timestamp1 = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();
    let code = auth.generate(30, timestamp1);
    return code;
}