TOTP utilities for Dart and Jaguar.dart
generateSecret
method on Totp
generates a Base32 encoded secret for use with TOTP.
// Generate secret for an account
final String secret = Totp.generateSecret();
print('secret');
makeUri
method on Totp
creates TOTP Uri from individual components.
// Create TOTP Uri
String uri = Totp.makeUri('teja', 'tejainece@gmail.com', secret);
print(uri);
// Generate for present time
print(Totp.generateCode(secret));
// Create TOTP Uri Qr code
final qr = new Qr(uri);
await qr.save('qr.png');
example/jaguar_otp_example.dart
// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:jaguar_otp/jaguar_otp.dart';
import 'package:jaguar_otp/src/qr.dart';
main() async {
// Generate secret for an account
final String secret = Totp.generateSecret();
print('secret');
// Create TOTP Uri
final String uri = Totp.makeUri('teja', 'tejainece@gmail.com', secret);
print(uri);
// Create TOTP Uri Qr code
final qr = new Qr(uri);
await qr.save('qr.png');
// Generate for present time
print(Totp.generateCode(secret));
}
Add this to your package's pubspec.yaml file:
dependencies:
jaguar_otp: ^0.1.0
You can install packages from the command line:
with pub:
$ pub get
Alternatively, your editor might support pub get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:jaguar_otp/jaguar_otp.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.1.0 | Jul 18, 2017 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
25
|
Health:
Code health derived from static analysis.
[more]
|
--
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
--
|
Overall:
Weighted score of the above.
[more]
|
13
|
The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.
Support Dart 2 in pubspec.yaml
.
The SDK constraint in pubspec.yaml
doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.
Make sure dartdoc
successfully runs on your package's source files. (-10 points)
Dependencies were not resolved.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.20.1 <2.0.0 |