GithubHelp home page GithubHelp logo

Comments (5)

RobThree avatar RobThree commented on May 23, 2024

You just generate some random strings/codes and store them with the useraccount. This is not something this library provides (you could use (part of) the output of the createSecret() method to generate some backup codes I guess).

from twofactorauth.

developing-off avatar developing-off commented on May 23, 2024

Ah okay can you show me a code how to do that ? i would generate 6 back up code

from twofactorauth.

RobThree avatar RobThree commented on May 23, 2024

Use a for-loop or something? The basics are:

  1. Generate X-number of codes using createCode() or any other means to generate a random string (make sure you have a decent amount of entropy, I suggest at least 10 bytes)
  2. Show codes to user
  3. Store codes in database or file or whatever

This is all highly dependent on your code, your environment, everything. There's no "THE" way to do this, there's infinite ways to do this (some better than others, ofcourse). But please understand that github issues are not a support forum for general programming questions. You might want to try stackoverflow or similar sites for that.

from twofactorauth.

willpower232 avatar willpower232 commented on May 23, 2024

I would suggest using something like bin2hex(random_bytes(10)) to create the secrets and then use whatever password hashing algorithm from the framework in use to store them securely.

from twofactorauth.

developing-off avatar developing-off commented on May 23, 2024

okay thank you for your help

from twofactorauth.

Related Issues (20)

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.