rust-otp
rust-otp is a modern, flexible Rust library for performing the HMAC-based One-time Password Algorithm (HOTP) as per RFC 4226 and the Time-based One-time Password Algorithm (TOTP) as per RFC 6238.
Features
- Modern Builder API: Easy and readable configuration for HOTP and TOTP.
- Async Support: Native
asyncmethods for seamless integration into modern runtimes. - Enhanced Security: Support for SHA1, SHA256, and SHA512.
- Formatted Output: Direct support for zero-padded strings.
- Zero Dependencies (core): Light-weight and secure.
Installation
Add this to your Cargo.toml:
[]
= "3.0.0"
To enable async support:
= { = "3.0.0", = ["async"] }
Usage
TOTP (Time-based One-time Password)
use ;
HOTP (HMAC-based One-time Password)
use ;
Async Usage
async
Running Examples
You can run the provided examples using cargo:
# Run HOTP example
# Run TOTP example
# Run Async TOTP example
License
rust-otp is licensed under the MIT license.
The full license is included in this repository in LICENSE.md.