ntc-ncrypto
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -136,9 +136,13 @@ /** | ||
// Remove right character '0' | ||
SSS.trimRight = function (s) { | ||
let i = s.length - 1; | ||
while (i >= 0 && s[i] === '0') { | ||
--i; | ||
// Remove right doubled characters '0' (zero byte in hex) | ||
SSS.trimRightDoubledZero = function (s) { | ||
let end = s.length; | ||
for (let i = s.length - 1; i > 2; i -= 2) { | ||
if (s[i] === '0' && s[i - 1] === '0') { | ||
end = i - 1; | ||
} else { | ||
break; | ||
} | ||
} | ||
return s.substring(0, i + 1); | ||
return end == s.length ? s : s.substring(0, end); | ||
}; | ||
@@ -159,3 +163,3 @@ | ||
// console.log("hexData: " + hexData); | ||
hexData = this.trimRight(hexData); | ||
hexData = this.trimRightDoubledZero(hexData); | ||
result = Buffer.from(hexData, 'hex').toString('utf8'); | ||
@@ -162,0 +166,0 @@ // console.log("result: " + result); |
{ | ||
"name": "ntc-ncrypto", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "ntc-ncrypto is a module node cryptography", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
67328
1260