Giter Site home page Giter Site logo

jiangts / js-otp Goto Github PK

View Code? Open in Web Editor NEW
258.0 258.0 71.0 117 KB

100% Javascript Implementation of HOTP and TOTP for Two-Factor Authentication.

Home Page: https://jiangts.github.io/JS-OTP

License: MIT License

CoffeeScript 7.13% JavaScript 88.47% HTML 4.28% Shell 0.12%

js-otp's People

Contributors

gmihaly-lmi avatar jiangts avatar runerune-sgt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-otp's Issues

Lack of credits/licence in jsOTP.js

Hi,

jsOTP.js Lack of credits and licence infos.

I added this in the file I use, inspired from jsOTP.min.js:

--- a/jsOTP.js
+++ b/jsOTP.js
@@ -1,3 +1,11 @@
+/*
+* File combining
+* (1) sha.js by Brian Turek 2008-2013 under BSD license
+* (2) and a modified js OTP implementation found on JSFiddle
+*
+* See https://github.com/jiangts/JS-OTP for more information
+*/
+
 (function() {
   var Hotp, Totp;
 

Failure to generate hotp with counter > 127

Hello,

Nice javascript. I receive an error when generating an hotp with a counter size > 127.

hotp.getOtp(secret,128) will fail: my console shows the following output:

URIError: malformed URI sequence
line 85 in Hotp.prototype.uintToString

Base64 implementation is broken

The implementation for Base64ToHex in this project is broken for Base64 strings that do not amount to a multiply of eight.

Replacing base32tohex in jsOTP.js fixes those issues:

base32tohex(base32) {

            let base32chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
            let bits = [];

            for (let i = 0; i < base32.length; i++) {
                let intVal = base32chars.indexOf(base32.charAt(i).toUpperCase());

                if (intVal === -1 || intVal === null) {
                    throw new Error("Invalid B64 char: " + base32.charAt(i));
                }

                let binaryRep = intVal.toString(2);
                let diffLen = 5 - binaryRep.length;

                for (let j = 0; j < diffLen; j++) {
                    bits.push("0");
                }

                for (let j = 0; j < binaryRep.length; j++) {
                    bits.push(binaryRep[j]);
                }
            }

            let hexstr = "";
            for (let i = 0; i < bits.length; i += 8) {
                let binByte = bits.slice(i, i + 8).join("");
                if (binByte.length < 8) {
                    continue;
                }
                let hexn = parseInt(binByte, 2).toString(16);

                hexstr += hexn.length === 2 ? hexn : "0" + hexn;
            }


            return hexstr;
}

No license specified

There's no code license, which means it's copyright infringement to actually use this library.

Having issue with Mega.nz totp generation

Hi, I'm trying to generate totp for mega.nz account which have 52 character secret. Google authenticator giving totp fine. But this js not working.
Can you look into it.

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.