otp 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 80

Build Status

dart-otp

RFC6238 Time-Based One-Time Password / Google Authenticator Library

Features:

Getting Started

Pubspec

pub.dartlang.org: (you can use 'any' instead of a version if you just want the latest always)

dependencies:
  otp: 1.0.1
#import('package:otp/otp.dart');

Start generating tokenss.

// Generate TOTP code.
OTP.generateTOTPCode("JBSWY3DPEHPK3PXP", 1362302550000); // -> 238158

// base32 decoding to original string.
OTP.generateHOTPCode("JBSWY3DPEHPK3PXP", 7); // -> 449891

API

OTP.generateTOTPCode(String secret, int currentTime, {int length: 6})

Generate a code for the provided secret and time.

  • secret - (String) A Base32 String.
  • currentTime - (int) The current time in milliseconds.
  • length - (int) the length of the resulting code.

Returns an int code.

OTP.generateHOTPCode(String secret, int counter, {int length: 6})

Generate a code for the provided secret and time.

  • secret - (String) A Base32 String.
  • counter - (int) An int counter.
  • length - (int) the length of the resulting code.

Returns an int code.

Testing

pub run test

Release notes

See CHANGELOG.md

v1.0.1

  • Cleanup and remove dead code

v1.0.0

  • Dart 2.0 updates

v0.1.0

  • Dart 1.0 Readiness

v0.0.4

  • Fixing crypto library.

v0.0.3

  • Fixing language changes.

v0.0.2

  • No functionality changes, just fixing a bad file state it git and in the package involving the case of the file.

v0.0.1

  • Initial Documented Release

example/example.dart

import "package:otp/otp.dart";

main() {
  var code = OTP.generateTOTPCode(
      "JBSWY3DPEHPK3PXP", DateTime.now().millisecondsSinceEpoch);
  print(code);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  otp: ^1.0.1

2. Install it

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 flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:otp/otp.dart';
  
Version Uploaded Documentation Archive
1.0.1 Aug 7, 2018 Go to the documentation of otp 1.0.1 Download otp 1.0.1 archive
1.0.0 Aug 7, 2018 Go to the documentation of otp 1.0.0 Download otp 1.0.0 archive
0.1.0 Nov 9, 2013 Go to the documentation of otp 0.1.0 Download otp 0.1.0 archive
0.0.4 Jun 5, 2013 Go to the documentation of otp 0.0.4 Download otp 0.0.4 archive
0.0.3 Apr 11, 2013 Go to the documentation of otp 0.0.3 Download otp 0.0.3 archive
0.0.2 Mar 4, 2013 Go to the documentation of otp 0.0.2 Download otp 0.0.2 archive
0.0.1 Mar 3, 2013 Go to the documentation of otp 0.0.1 Download otp 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:otp/otp.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.13.0 <3.0.0
base32 >=1.0.1 <2.0.0 1.0.1
crypto ^2.0.0 2.0.6
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.0.2
typed_data 1.1.6
Dev dependencies
test any