Skip to content

kingrongH/totp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TOTP project is used for calculate a Time-based One-time Password For more infomation, please check the link above

Quick Start

git clone https://github.com/kingrongH/totp
cd totp
cargo run XW7HPZJ2L3AMPWQN

Example

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(())
}

Update

  • 2019.9.29: Change the secret type to &[u8]

LICENSE

under MIT LICENSE

About

Rust implementation of totp algorithm

Resources

License

Stars

Watchers

Forks

Languages