Crates.io | otp-rs |
lib.rs | otp-rs |
version | 0.1.1 |
source | src |
created_at | 2021-11-18 10:08:23.908459 |
updated_at | 2021-11-18 10:52:57.959486 |
description | RFC-complaint one-time password algorithms written in Rust |
homepage | https://github.com/russellwmy/otp-rs |
repository | https://github.com/russellwmy/otp-rs |
max_upload_size | |
id | 483903 |
size | 8,424 |
RFC-complaint one-time password algorithms written in Rust.
The HMAC-based one-time password algorithm is implemented as per RFC4226. The time-based one-time password algorithm is implemented as per RFC 6238.
[dependencies]
otp-rs= "0.1"
let otp = HOTP::new("secret");
/// Generate code with counter 0 input
let code = otp.generate(0).unwrap();
println!("{}", code);
let otp = TOTP::new("secret");
/// Generate code with period and current timestamp
let timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs();
let code = otp.generate(30, timestamp);
println!("{}", code);