dart_otp

Creator: coderz1093

Last updated:

0 purchases

dart_otp Image
dart_otp Images

Languages

Categories

Add to Cart

Description:

dart otp

dart_otp #



dart_otp is a dart package to generate and verify one-time passwords that were used to implement 2FA and MFA authentication method in web applications and other login-required systems.
The package was implement based on RFC4226 (HOTP: An HMAC-Based One-Time Password Algorithm) and RFC6238 (TOTP: Time-Based One-Time Password Algorithm).
Feature #

Create and verify a HOTP object
Create and verify a TOTP object
Generate a otpauth url with the b32 encoded string
Support for OTP tokens encrypted with SHA1, SHA256, SHA384 and SHA512

Installation #
Pubspec
Add dart_otp as a dependency in your pubspec.yaml file.
dependencies:
dart_otp: ^1.3.0
copied to clipboard
Example #
Time-based OTPs
import 'package:dart_otp/dart_otp.dart';

void main() {

/// default initialization for intervals of 30 seconds and 6 digit tokens
TOTP totp = TOTP(secret: "J22U6B3WIWRRBTAV");

/// initialization for custom interval and digit values
TOTP totp = TOTP(secret: "J22U6B3WIWRRBTAV", interval: 60, digits: 8);

totp.now(); /// => 432143

/// verify for the current time
totp.verify(otp: 432143); /// => true

/// verify after 30s
totp.verify(otp: 432143); /// => false
}
copied to clipboard
Counter-based OTPs
import 'package:dart_otp/dart_otp.dart';

void main() {

/// default initialization 6 digit tokens
HOTP hotp = HOTP(secret: "J22U6B3WIWRRBTAV");

/// initialization for custom digit value
HOTP hotp = HOTP(secret: "J22U6B3WIWRRBTAV", counter: 50, digits: 8);

hotp.at(counter: 0); /// => 432143
hotp.at(counter: 1); /// => 231434
hotp.at(counter: 2132); /// => 242432

/// verify with a counter
hotp.verify(otp: 242432, counter: 2132); /// => true
hotp.verify(otp: 242432, counter: 2133); /// => false
}
copied to clipboard
Release notes #
See CHANGELOG.md.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.