Merge pull request #27 from homakov/patch-1

Fix bug when v is < 1000000 and substr fails
This commit is contained in:
Guy Halford-Thompson 2015-08-07 11:48:56 -07:00
commit 3db472249f

View File

@ -43,9 +43,9 @@ hotp.gen = function(key, opt) {
(h[offset + 2] & 0xff) << 8 |
(h[offset + 3] & 0xff);
v = v + '';
v = (v % 1000000) + '';
return v.substr(v.length - p, p);
return Array(7-v.length).join('0') + v;
};
/**