| Crates.io | otp-auth |
| lib.rs | otp-auth |
| version | 0.1.0 |
| created_at | 2025-07-15 21:05:54.295897+00 |
| updated_at | 2025-07-15 21:05:54.295897+00 |
| description | A Rust Implementation of HMAC and Time-based One-Time Passwords. |
| homepage | https://github.com/prafitradimas/otp-auth |
| repository | https://github.com/prafitradimas/otp-auth.git |
| max_upload_size | |
| id | 1753990 |
| size | 83,592 |
A Rust implementation of HOTP and TOTP based one-time passwords.
use otp::{Totp, Algorithm, Secret};
let totp = Totp::new(
Algorithm::SHA1,
"example.com".into(),
"user@example.com".into(),
6,
30,
Secret::from_bytes(b"my-secret"),
);
let timestamp = 1_720_000_000; // example UNIX timestamp
let otp = totp.generate_at(timestamp);
assert!(totp.verify(otp, timestamp, 1));
This work is released under the MIT license. A copy of the license is provided in the LICENSE file.