Giter Site home page Giter Site logo

apollonbar / totp.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wuyanxin/totp.js

0.0 0.0 0.0 91 KB

🎲TOTP(Time-based one-time password) generator, support for Google Authenticator

Home Page: http://t.cn/RnaSS4n

License: MIT License

JavaScript 100.00%

totp.js's Introduction

totp.js

Two-factor authentication implementation in pure javascript. One-time password generator (HOTP/TOTP) with support for Google Authenticator.

Build Status Node.js >= 8.x MIT Licence

Live Demo

Preview

preview

Demo

Getting Started

Install

npm i totp.js

Node.js

const TOTP = require('totp.js');

// generate a base32 secret key
const key = TOTP.randomKey();
// 'GAXGGYT2OU2DEOJR'

const totp = new TOTP(key);
const code = totp.genOTP();
// '552179'
totp.verify(code)
// true

// generate Google Authenticator supported URL
totp.gaURL('[email protected]', 'Totp.js')
// 'otpauth://totp/[email protected]?issuer=Totp.js&secret=GAXGGYT2OU2DEOJR'

// OR
const totp2 = new TOTP(TOTP.base32.encode('your key'));
totp2.genOTP()

For Browser

<script src="./dist/totp.min.js" />
<script>
  var key = TOTP.randomKey();
  var totp = new TOTP(key);
  console.log(totp.genOTP());
</script>

Enjoy!

Lisence

© MIT

totp.js's People

Contributors

wuyanxin 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.