rs-crypto-otp 0.1.0
HOTP and TOTP one-time passwords (RFC 4226 and 6238) with base32 secrets and otpauth URIs
Install
cargo add rs-crypto-otp --registry rupm
In Ruststudio: Packages, search for rs-crypto-otp, Install.
Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.
Versions
- 0.1.0 2026-11-23
README
# rs-crypto-otp
HOTP and TOTP one-time passwords (RFC 4226 and 6238) with base32 secrets and otpauth URIs
Add it with `rupm add rs-crypto-otp` (or `cargo add rs-crypto-otp --registry rupm`).
Matches the RFC 4226 and RFC 6238 test vectors, with the hashes built in (std only). The hashes are unaudited and not constant-time, so this crate is not meant for security-critical use; use an audited crate for a real authentication system.
```rust
use rs_crypto_otp::{hotp, Algorithm};
// RFC 4226 test secret, counter 0.
assert_eq!(hotp(b"12345678901234567890", 0, 6, Algorithm::Sha1).unwrap(), "755224");
let secret = rs_crypto_otp::base32_decode("JBSWY3DPEHPK3PXP").unwrap();
let code = rs_crypto_otp::totp(&secret, 59, 30, 6, Algorithm::Sha1).unwrap();
assert_eq!(code.len(), 6);
```