Giter Club home page Giter Club logo

f_autheticator's Introduction

f_authenticator

Features

Easy Configuration

  • Configure TOTP generation parameters such as algorithm, interval, key length, and more.
  • Automatic secret generation if not provided, ensuring convenience and security.

TOTP Generation

  • Generate TOTP codes in both integer and string formats.
  • Retrieve a URL link for the authenticator, simplifying integration into authenticator apps.

Stream-Based Functionality

  • Continuously receive updated TOTP codes through a stream-based approach.
  • Stream TOTP codes in both integer and string formats for real-time usage.

Usage

The FAuthenticator class provides functionalities to generate and manage TOTP codes for 2FA. Here's a basic example:

import the library in your Dart code:

import 'package:f_authenticator/f_authenticator.dart';
void main() {
  // Initialize the authenticator
  FAuthenticator authenticator = FAuthenticator(
    appName: 'YourAppName',
    username: '[email protected]',
  );

  // Get the TOTP link for setup
  String totpLink = authenticator.getLink;

  // Generate a random secret
  String randomSecret = authenticator.getRandomSecret;

  // Get the current TOTP code as a string
  String currentCodeString = authenticator.getCurrentStringCode;

  // Get the current TOTP code as an integer
  int currentCode = authenticator.getCurrentCode;

  // Access the TOTP code as a stream
  Stream<int> codeStream = authenticator.getCodeStream();
  // Stream<String> stringCodeStream = authenticator.getStringCodeStream();

  // Subscribe to the stream for real-time code updates
  codeStream.listen((code) {
    print('Current code: $code');
    // Perform actions with the updated code
  });
}

Methods

  • getLink: Generates a TOTP URL link for the authenticator.
  • getRandomSecret: Retrieves a randomly generated secret.
  • getCurrentSecret: Retrieves the current secret used for generating TOTP codes.
  • getCurrentStringCode: Generates the current TOTP code as a string.
  • getCurrentCode: Generates the current TOTP code as an integer.
  • getCodeStream: Provides a stream of updated TOTP codes.
  • getStringCodeStream: Provides a stream of updated TOTP codes as strings.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.

License

This library is licensed under the MIT License. See the LICENSE file for details.

f_autheticator's People

Contributors

odinachi avatar

Stargazers

George  Ikwegbu Chinedu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.