From d22e49fbe6978b55e3a61774639e945ce83cae73 Mon Sep 17 00:00:00 2001 From: Sparkle Date: Thu, 8 Sep 2022 10:35:09 +0800 Subject: [PATCH 1/3] fix bug for epic key --- js/jsOTP.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/jsOTP.js b/js/jsOTP.js index 4896746..a1ba36a 100644 --- a/js/jsOTP.js +++ b/js/jsOTP.js @@ -53,6 +53,7 @@ epoch = Math.round(now / 1000.0); time = this.leftpad(this.dec2hex(Math.floor(epoch / this.expiry)), 16, "0"); shaObj = new jsSHA("SHA-1", "HEX"); + if (key.length % 2 !== 0) key = key.substring(0,key.length-1); shaObj.setHMACKey(key, "HEX"); shaObj.update(time); hmac = shaObj.getHMAC("HEX"); From c293751d6d136ee4ebdf7bced2dccc4fa2f88c59 Mon Sep 17 00:00:00 2001 From: Sparkle Date: Thu, 8 Sep 2022 10:37:35 +0800 Subject: [PATCH 2/3] fix bug for epic key --- dist/jsOTP.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/jsOTP.js b/dist/jsOTP.js index 23a40c1..9ffa568 100644 --- a/dist/jsOTP.js +++ b/dist/jsOTP.js @@ -53,6 +53,7 @@ epoch = Math.round(now / 1000.0); time = this.leftpad(this.dec2hex(Math.floor(epoch / this.expiry)), 16, "0"); shaObj = new jsSHA("SHA-1", "HEX"); + if (key.length % 2 !== 0) key = key.substring(0,key.length-1); shaObj.setHMACKey(key, "HEX"); shaObj.update(time); hmac = shaObj.getHMAC("HEX"); From 77e5b72053ca8ee6a76d2aeee4949ce018bedae2 Mon Sep 17 00:00:00 2001 From: Sparkle Date: Thu, 8 Sep 2022 10:38:16 +0800 Subject: [PATCH 3/3] fix bug for epic key --- dist/jsOTP-es5.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/jsOTP-es5.js b/dist/jsOTP-es5.js index 31bb8f6..1203be8 100644 --- a/dist/jsOTP-es5.js +++ b/dist/jsOTP-es5.js @@ -76,6 +76,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons epoch = Math.round(now / 1000.0); time = this.leftpad(this.dec2hex(Math.floor(epoch / this.expiry)), 16, "0"); shaObj = new jsSHA("SHA-1", "HEX"); + if (key.length % 2 !== 0) key = key.substring(0,key.length-1); shaObj.setHMACKey(key, "HEX"); shaObj.update(time); hmac = shaObj.getHMAC("HEX");