ttlock-sdk-js
ttlock-sdk-js copied to clipboard
CodecUtils.decodeWithEncrypt not correct for null key
Hello,
If key is null then p0.length for initial crc should be 1 less in CodecUtils.decodeWithEncrypt
===========================================
diff --git a/src/util/CodecUtils.ts b/src/util/CodecUtils.ts
index 67b410b..5748cbf 100644
--- a/src/util/CodecUtils.ts
+++ b/src/util/CodecUtils.ts
@@ -40,7 +40,7 @@ export class CodecUtils {
}
var decoded = [];
- const crc = dscrc_table[p0.length & 0xff];
+ const crc = dscrc_table[(p0.length - (key ? 0 : 1)) & 0xff];
for (var i = 0; i < p0.length - (key ? 0 : 1); i++) {
Hi, thanks for the correction
Can you PR this so @kind3r can take a look at it easier?