Update TOTP-algorithm/Rust-TOTP-algorithm.md

main
kirbylife 2024-01-27 06:36:38 +00:00
parent 442e55c980
commit 56bfe5ba80
1 changed files with 10 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# Implementation of the TOTP algorithm in Rust
```Rust
// src/main.rs
use base32::decode;
use chrono::Utc;
use sha1::{digest::Update, Digest, Sha1};
@ -44,5 +45,14 @@ fn generate() {
println!("{:06}", token);
}
```
```toml
[package]
...
[dependencies]
base32 = "0.4.0"
chrono = "0.4.33"
sha1 = "0.10.6"
```