mirror of
https://github.com/adulau/hotp-js.git
synced 2024-12-21 16:26:10 +00:00
added 7 and 8 decimals HOTP output
This commit is contained in:
parent
1304af58ef
commit
d30f1b3dd1
2 changed files with 7 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue