Closed blizzardengle closed 3 years ago
Hi, Your fix does not seem to work. My suggestion is this: var checklength = bits.length - bits.length % 8; i = 0; while (i + 4 <= checklength) { chunk = bits.substr(i, 4); hex = hex + parseInt(chunk, 2).toString(16); i += 4; }
Based on that in a working totp generator the last standalone HEX digit is ignored.
Some websites and providers generate a secret key that technically is not the proper length to use in generating a OTP. If you pad from the left when such a secret key is detected you can fix the key length without altering the output. This is needed for example with websites like Amazon that currently return a 52 character secret key.
NOTE: This changes was only done in the
jsOTP-es5.js
andjsOTP.js
files. These files still need to be minified and then minified gzipped.