From 0824117e6b0ceb6fbf2249b9df5a206f858f70a9 Mon Sep 17 00:00:00 2001 From: ZanderCodes Date: Mon, 2 Mar 2020 12:54:43 +0100 Subject: [PATCH 1/2] Fix TOTP View Amazon TOTP not view in nextcloud because bits are not correct. Signed-off-by: ZanderCodes --- js/app/directives/otp.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/app/directives/otp.js b/js/app/directives/otp.js index 9bbb0f07..d8ad8a92 100644 --- a/js/app/directives/otp.js +++ b/js/app/directives/otp.js @@ -52,6 +52,10 @@ var val = base32chars.indexOf(base32.charAt(i).toUpperCase()); bits += leftpad(val.toString(2), 5, '0'); } + + for (i = i % 8; i > 0; i--) { + bits += leftpad('0', 5, '0'); + } for (i = 0; i + 4 <= bits.length; i += 4) { var chunk = bits.substr(i, 4); From 4384f8e4de7a70ac75802807129b19043528c1d9 Mon Sep 17 00:00:00 2001 From: ZanderCodes Date: Wed, 4 Mar 2020 18:22:41 +0100 Subject: [PATCH 2/2] Fix 16 Bits Codes Signed-off-by: ZanderCodes --- js/app/directives/otp.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/js/app/directives/otp.js b/js/app/directives/otp.js index d8ad8a92..69e5b608 100644 --- a/js/app/directives/otp.js +++ b/js/app/directives/otp.js @@ -52,16 +52,12 @@ var val = base32chars.indexOf(base32.charAt(i).toUpperCase()); bits += leftpad(val.toString(2), 5, '0'); } - - for (i = i % 8; i > 0; i--) { - bits += leftpad('0', 5, '0'); - } for (i = 0; i + 4 <= bits.length; i += 4) { var chunk = bits.substr(i, 4); hex = hex + parseInt(chunk, 2).toString(16); } - return hex; + return hex.length % 2 ? hex + "0" : hex; } @@ -128,4 +124,4 @@ }; } ]); -}()); \ No newline at end of file +}());