totp 0.1.0

SDKdartflutter
Platformandroidioswindowslinuxmacosweb

An implementation of the Time-based One-time Password (TOTP).

Time-based One-Time Password (TOTP)

This is an implementation of the TOTP algorithm as specified in RFC 6238.

pub version

Installation

Add the following to your pubspec.yaml:

dependencies:
  totp: latest

Or install it from the command line:

dart pub add totp

Usage

import 'package:totp/totp.dart';

final totp = Totp(secret: '12345678901234567890'.codeUnits);

print(totp.now());

If you want to use a base32 encoded secret, you can use the fromBase32 constructor:

final totp = Totp.fromBase32(
  secret: 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ',
);

APIs

MethodReturn typeDescription
generateStringGenerates a new password with a DateTime
nowStringGenerates a new password with DateTime.now()
validateboolValidates a password with a DateTime
remainingintGenerate remaining time by calculate from period and DateTime

License

The project is licensed under the MIT license.