totp
0.2.0, released 8 days ago by odroe.com
Generate and verify Time-based One-time Passwords (TOTP) following RFC 6238.
WASM-ready
What it does
An implementation of the Time-based One-time Password algorithm that generates tokens, verifies codes with optional symmetric windows, and calculates remaining time periods with subsecond precision. It supports base32 keys and various cryptographic hash algorithms.
AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to implement multi-factor authentication (MFA) or two-factor authentication (2FA).
- You are building a client that needs to generate or verify RFC 6238 compliant TOTP tokens.
Skip it when
- You need built-in state persistence or automatic replay attack prevention during verification.
Strengths
- Follows the RFC 6238 specification strictly.
- Supports customizable algorithms (SHA1, SHA256, SHA512), periods, and digit counts.
- Provides precise Duration-based time remaining calculations.
Weaknesses
- Verification does not persist state or prevent replay, requiring manual tracking in your application.
- Limited to Dart 3.13 or later.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
import 'package:totp/totp.dart';
void main() {
final totp = Totp.fromBase32(secret: 'JBSWY3DPEHPK3PXP');
print(totp.generate());
}Alternatives
Packages that do the same job and could replace totp.