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
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or packages 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 |
|
|
We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
13 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
100 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
57 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:jaguar_otp/jaguar_otp.dart
.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*
, it usually means that the author is still experimenting with the general direction API.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.20.1 <2.0.0 | ||
base32 | ^0.1.2 | 0.1.2 | 1.0.0+1 |
crypto | ^2.0.1 | 2.0.2+1 | |
http | ^0.11.3 | 0.11.3+16 | |
Transitive dependencies | |||
async | 2.0.6 | ||
charcode | 1.1.1 | ||
collection | 1.14.9 | ||
convert | 2.0.1 | ||
http_parser | 3.1.1 | ||
path | 1.5.1 | ||
source_span | 1.4.0 | ||
string_scanner | 1.0.2 | ||
typed_data | 1.1.5 | ||
Dev dependencies | |||
test | ^0.12.0 |