totp 0.1.0
totp: ^0.1.0 copied to clipboard
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.
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 #
Method | Return type | Description |
---|---|---|
generate |
String |
Generates a new password with a DateTime |
now |
String |
Generates a new password with DateTime.now() |
validate |
bool |
Validates a password with a DateTime |
remaining |
int |
Generate remaining time by calculate from period and DateTime |
License #
The project is licensed under the MIT license.