cyberchef 9.50.11 → 9.50.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/operations/Fletcher32Checksum.mjs +11 -3
- package/src/core/operations/Fletcher64Checksum.mjs +15 -3
- package/tests/operations/index.mjs +1 -0
- package/tests/operations/tests/FletcherChecksum.mjs +108 -0
- package/tests/operations/tests/GenerateAllHashes.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyberchef",
|
|
3
|
-
"version": "9.50.
|
|
3
|
+
"version": "9.50.12",
|
|
4
4
|
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
|
5
5
|
"author": "n1474335 <n1474335@gmail.com>",
|
|
6
6
|
"homepage": "https://gchq.github.io/CyberChef",
|
|
@@ -35,10 +35,18 @@ class Fletcher32Checksum extends Operation {
|
|
|
35
35
|
run(input, args) {
|
|
36
36
|
let a = 0,
|
|
37
37
|
b = 0;
|
|
38
|
-
|
|
38
|
+
if (ArrayBuffer.isView(input)) {
|
|
39
|
+
input = new DataView(input.buffer, input.byteOffset, input.byteLength);
|
|
40
|
+
} else {
|
|
41
|
+
input = new DataView(input);
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
for (let i = 0; i < input.
|
|
41
|
-
a = (a + input
|
|
44
|
+
for (let i = 0; i < input.byteLength - 1; i += 2) {
|
|
45
|
+
a = (a + input.getUint16(i, true)) % 0xffff;
|
|
46
|
+
b = (b + a) % 0xffff;
|
|
47
|
+
}
|
|
48
|
+
if (input.byteLength % 2 !== 0) {
|
|
49
|
+
a = (a + input.getUint8(input.byteLength - 1)) % 0xffff;
|
|
42
50
|
b = (b + a) % 0xffff;
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -35,10 +35,22 @@ class Fletcher64Checksum extends Operation {
|
|
|
35
35
|
run(input, args) {
|
|
36
36
|
let a = 0,
|
|
37
37
|
b = 0;
|
|
38
|
-
|
|
38
|
+
if (ArrayBuffer.isView(input)) {
|
|
39
|
+
input = new DataView(input.buffer, input.byteOffset, input.byteLength);
|
|
40
|
+
} else {
|
|
41
|
+
input = new DataView(input);
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
for (let i = 0; i < input.
|
|
41
|
-
a = (a + input
|
|
44
|
+
for (let i = 0; i < input.byteLength - 3; i += 4) {
|
|
45
|
+
a = (a + input.getUint32(i, true)) % 0xffffffff;
|
|
46
|
+
b = (b + a) % 0xffffffff;
|
|
47
|
+
}
|
|
48
|
+
if (input.byteLength % 4 !== 0) {
|
|
49
|
+
let lastValue = 0;
|
|
50
|
+
for (let i = 0; i < input.byteLength % 4; i++) {
|
|
51
|
+
lastValue = (lastValue << 8) | input.getUint8(input.byteLength - 1 - i);
|
|
52
|
+
}
|
|
53
|
+
a = (a + lastValue) % 0xffffffff;
|
|
42
54
|
b = (b + a) % 0xffffffff;
|
|
43
55
|
}
|
|
44
56
|
|
|
@@ -125,6 +125,7 @@ import "./tests/LS47.mjs";
|
|
|
125
125
|
import "./tests/LZString.mjs";
|
|
126
126
|
import "./tests/NTLM.mjs";
|
|
127
127
|
import "./tests/Shuffle.mjs";
|
|
128
|
+
import "./tests/FletcherChecksum.mjs";
|
|
128
129
|
|
|
129
130
|
// Cannot test operations that use the File type yet
|
|
130
131
|
// import "./tests/SplitColourChannels.mjs";
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author mikecat
|
|
3
|
+
* @copyright Crown Copyright 2022
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import TestRegister from "../../lib/TestRegister.mjs";
|
|
7
|
+
|
|
8
|
+
TestRegister.addTests([
|
|
9
|
+
{
|
|
10
|
+
name: "Fletcher-16 Checksum: abcde",
|
|
11
|
+
input: "abcde",
|
|
12
|
+
expectedOutput: "c8f0",
|
|
13
|
+
recipeConfig: [
|
|
14
|
+
{
|
|
15
|
+
op: "Fletcher-16 Checksum",
|
|
16
|
+
args: [],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "Fletcher-16 Checksum: abcdef",
|
|
22
|
+
input: "abcdef",
|
|
23
|
+
expectedOutput: "2057",
|
|
24
|
+
recipeConfig: [
|
|
25
|
+
{
|
|
26
|
+
op: "Fletcher-16 Checksum",
|
|
27
|
+
args: [],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "Fletcher-16 Checksum: abcdefgh",
|
|
33
|
+
input: "abcdefgh",
|
|
34
|
+
expectedOutput: "0627",
|
|
35
|
+
recipeConfig: [
|
|
36
|
+
{
|
|
37
|
+
op: "Fletcher-16 Checksum",
|
|
38
|
+
args: [],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "Fletcher-32 Checksum: abcde",
|
|
44
|
+
input: "abcde",
|
|
45
|
+
expectedOutput: "f04fc729",
|
|
46
|
+
recipeConfig: [
|
|
47
|
+
{
|
|
48
|
+
op: "Fletcher-32 Checksum",
|
|
49
|
+
args: [],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "Fletcher-32 Checksum: abcdef",
|
|
55
|
+
input: "abcdef",
|
|
56
|
+
expectedOutput: "56502d2a",
|
|
57
|
+
recipeConfig: [
|
|
58
|
+
{
|
|
59
|
+
op: "Fletcher-32 Checksum",
|
|
60
|
+
args: [],
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "Fletcher-32 Checksum: abcdefgh",
|
|
66
|
+
input: "abcdefgh",
|
|
67
|
+
expectedOutput: "ebe19591",
|
|
68
|
+
recipeConfig: [
|
|
69
|
+
{
|
|
70
|
+
op: "Fletcher-32 Checksum",
|
|
71
|
+
args: [],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "Fletcher-64 Checksum: abcde",
|
|
77
|
+
input: "abcde",
|
|
78
|
+
expectedOutput: "c8c6c527646362c6",
|
|
79
|
+
recipeConfig: [
|
|
80
|
+
{
|
|
81
|
+
op: "Fletcher-64 Checksum",
|
|
82
|
+
args: [],
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "Fletcher-64 Checksum: abcdef",
|
|
88
|
+
input: "abcdef",
|
|
89
|
+
expectedOutput: "c8c72b276463c8c6",
|
|
90
|
+
recipeConfig: [
|
|
91
|
+
{
|
|
92
|
+
op: "Fletcher-64 Checksum",
|
|
93
|
+
args: [],
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "Fletcher-64 Checksum: abcdefgh",
|
|
99
|
+
input: "abcdefgh",
|
|
100
|
+
expectedOutput: "312e2b28cccac8c6",
|
|
101
|
+
recipeConfig: [
|
|
102
|
+
{
|
|
103
|
+
op: "Fletcher-64 Checksum",
|
|
104
|
+
args: [],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
]);
|