Skip to content
pubscout

dart_dash_otp

2.0.0, released 6 months ago by datogedon.com

Generate and verify TOTP and HOTP one-time passwords for 2FA and MFA.

WASM-ready
$ flutter pub add dart_dash_otp
Source repository

What it does

Generates and verifies time-based (TOTP) and counter-based (HOTP) one-time passwords adhering to RFC 6238 and RFC 4226. Supports parsing and generating Google Authenticator otpauth:// URIs, drift tolerance, and secure Base32 secret generation.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to implement two-factor or multi-factor authentication in a Dart or Flutter application.
  • You need to generate or parse Google Authenticator otpauth:// URIs for QR codes.

Skip it when

  • You require client-side storage or server-side counter persistence out of the box without building it yourself.

Strengths

  • RFC test-vector validated against RFC 4226 and RFC 6238 reference vectors.
  • Constant-time verification to prevent timing attacks.
  • Pure Dart with zero Flutter dependencies, supporting multiple algorithms (SHA-1, SHA-256, SHA-384, SHA-512).

Weaknesses

  • Requires manual implementation of server-side counter persistence and secret management.
  • On the web, integers are exact only up to 2^53, so extremely large HOTP counters require a native-int target.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2

not documented

import 'package:dart_dash_otp/dart_dash_otp.dart';

void main() {
  final totp = TOTP(secret: OTP.randomSecret());

  final code = totp.now();
  final ok = totp.verify(otp: code);

  print('Code $code is valid: $ok');
}

Alternatives

Packages that do the same job and could replace dart_dash_otp.

Works with

Packages commonly used together with dart_dash_otp: ones it builds on, ones built on it, and its own family.