added 7 and 8 decimals HOTP output

This commit is contained in:
Alexandre Dulaunoy 2009-12-18 22:02:09 +01:00
parent 1304af58ef
commit d30f1b3dd1
2 changed files with 7 additions and 1 deletions

View file

@ -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("<br />");
}
</script>

View file

@ -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";