diff --git a/example.html b/example.html index 0e4e9b7..1b7436e 100644 --- a/example.html +++ b/example.html @@ -20,8 +20,10 @@ for (var i=0; i<10; i++) { document.write("count: "+i); document.write(" hex40 (used in ootp): "); document.write(hotp("3132333435363738393031323334353637383930",i,"hex40")); - document.write(" HOTP value: "); + document.write(" HOTP value: (dec6)"); document.write(hotp("3132333435363738393031323334353637383930",i,"dec6")); + document.write(" HOTP value: (dec8)"); + document.write(hotp("3132333435363738393031323334353637383930",i,"dec8")); document.write("
"); } diff --git a/hotp/hotp.js b/hotp/hotp.js index 0137209..694e83e 100644 --- a/hotp/hotp.js +++ b/hotp/hotp.js @@ -92,6 +92,10 @@ function hotp(key, counter, format) { return hmacBytes.substring(0, 10); } else if (format == "dec6") { return truncatedvalue(Crypto.util.hexToBytes(hmacBytes), 6); + } else if (format == "dec7") { + return truncatedvalue(Crypto.util.hexToBytes(hmacBytes), 7); + } else if (format == "dec8") { + return truncatedvalue(Crypto.util.hexToBytes(hmacBytes), 8); } else { return "unknown format";