From 6c07d817e625e68879c96b3f170752022a4ac8fa Mon Sep 17 00:00:00 2001 From: Slava Bacherikov Date: Fri, 26 Jan 2018 19:14:52 +0200 Subject: [PATCH] Add incrementData method to dell encoder --- src/dell/encode.ts | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/dell/encode.ts b/src/dell/encode.ts index 1964f43..1a7d4f7 100644 --- a/src/dell/encode.ts +++ b/src/dell/encode.ts @@ -131,6 +131,17 @@ class Tag595BEncoder { return this.A + this.f1(temp, this.md5table[key2] + this.encBlock[key1]) | 0; } + protected incrementData() { + this.encData[0] += this.A; + this.encData[1] += this.B; + this.encData[2] += this.C; + this.encData[3] += this.D; + + this.encData.forEach((val, index) => { + this.encData[index] = val | 0; + }); + } + public makeEncode(): void { let t: number = 0; for (let i = 0; i < 64; i++) { @@ -154,10 +165,7 @@ class Tag595BEncoder { this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; } - this.encData[0] += this.A; - this.encData[1] += this.B; - this.encData[2] += this.C; - this.encData[3] += this.D; + this.incrementData(); } public result(): number[] { @@ -235,10 +243,7 @@ class Tag1F66Encoder extends Tag595BEncoder { this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; } - this.encData[0] += this.A; - this.encData[1] += this.B; - this.encData[2] += this.C; - this.encData[3] += this.D; + this.incrementData(); } for (let j = 0; j < 21; j++) { @@ -270,10 +275,7 @@ class Tag1F66Encoder extends Tag595BEncoder { this.B = rol(t, rotationTable[g & 3][i & 3]) + this.B | 0; } - this.encData[0] += this.A; - this.encData[1] += this.B; - this.encData[2] += this.C; - this.encData[3] += this.D; + this.incrementData(); } } } @@ -317,10 +319,7 @@ class Tag6FF1Encoder extends Tag595BEncoder { this.B = rol(t, rotationTable[i >> 4][i & 3]) + this.B | 0; } - this.encData[0] += this.A; - this.encData[1] += this.B; - this.encData[2] += this.C; - this.encData[3] += this.D; + this.incrementData(); } for (let j = 0; j < 17; j++) { @@ -352,10 +351,7 @@ class Tag6FF1Encoder extends Tag595BEncoder { this.B = rol(t, rotationTable[g & 3][i & 3]) + this.B | 0; } - this.encData[0] += this.A; - this.encData[1] += this.B; - this.encData[2] += this.C; - this.encData[3] += this.D; + this.incrementData(); } } }