From fb71ea31983f77562e1d53276a8a39bcd0780b41 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 8 Dec 2017 14:43:08 +0100 Subject: [PATCH] Bug fix --- NfcKeyJS.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NfcKeyJS.js b/NfcKeyJS.js index 2b2ce1a..d9786a4 100644 --- a/NfcKeyJS.js +++ b/NfcKeyJS.js @@ -82,8 +82,8 @@ NfcKey.prototype = (function () { var tohex = function (b, l) { var h = b.toString(16).toUpperCase(); - if (h.length % 2 !== 0) - return '0' + h; + while (l && h.length < l / 4) + h = '0' + h; return h; }; @@ -108,7 +108,7 @@ NfcKey.prototype = (function () { for (i = 0; i < 4; i++) intKey = transfUid[i + offset] + ((intKey << 8) >>> 0); - return tohex(swap32(intKey)); + return tohex(swap32(intKey), 32); }, getPack: function (uid) { @@ -128,7 +128,7 @@ NfcKey.prototype = (function () { intPack += transfUid[i] * 13; var res = ((intPack ^ 0x5555) >>> 0) & 0xFFFF; - return tohex(swap16(res)); + return tohex(swap16(res), 16); } };