pdf-codec 1.4.2 → 1.5.0
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/README.md +20 -12
- package/dist/content-write.cjs +2 -3
- package/dist/content-write.js +1 -2
- package/dist/crypto/aes.cjs +166 -0
- package/dist/crypto/aes.d.cts +6 -0
- package/dist/crypto/aes.d.ts +6 -0
- package/dist/crypto/aes.js +163 -0
- package/dist/crypto/md5.cjs +215 -0
- package/dist/crypto/md5.d.cts +4 -0
- package/dist/crypto/md5.d.ts +4 -0
- package/dist/crypto/md5.js +214 -0
- package/dist/crypto/rc4.cjs +29 -0
- package/dist/crypto/rc4.d.cts +4 -0
- package/dist/crypto/rc4.d.ts +4 -0
- package/dist/crypto/rc4.js +28 -0
- package/dist/crypto/sha2.cjs +261 -0
- package/dist/crypto/sha2.d.cts +6 -0
- package/dist/crypto/sha2.d.ts +6 -0
- package/dist/crypto/sha2.js +258 -0
- package/dist/diagnostics.cjs +7 -0
- package/dist/diagnostics.d.cts +4 -1
- package/dist/diagnostics.d.ts +4 -1
- package/dist/diagnostics.js +7 -1
- package/dist/document.cjs +38 -2
- package/dist/document.js +38 -2
- package/dist/encrypt.cjs +264 -0
- package/dist/encrypt.d.cts +11 -0
- package/dist/encrypt.d.ts +11 -0
- package/dist/encrypt.js +263 -0
- package/dist/filters.cjs +19 -1
- package/dist/filters.js +19 -1
- package/dist/image/ccitt.cjs +488 -0
- package/dist/image/ccitt.d.cts +17 -0
- package/dist/image/ccitt.d.ts +17 -0
- package/dist/image/ccitt.js +487 -0
- package/dist/images-read.cjs +1 -4
- package/dist/images-read.js +2 -5
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/interpret.cjs +173 -38
- package/dist/interpret.d.cts +27 -10
- package/dist/interpret.d.ts +27 -10
- package/dist/interpret.js +174 -39
- package/dist/math-font-write.cjs +1 -1
- package/dist/math-font-write.js +1 -1
- package/dist/{matrix-B3c2_a2f.d.cts → matrix-BHzJESll.d.cts} +2 -1
- package/dist/{matrix-B3c2_a2f.d.ts → matrix-BHzJESll.d.ts} +2 -1
- package/dist/matrix.cjs +2 -0
- package/dist/matrix.d.cts +2 -2
- package/dist/matrix.d.ts +2 -2
- package/dist/matrix.js +2 -1
- package/dist/objects.cjs +4 -0
- package/dist/objects.d.cts +2 -1
- package/dist/objects.d.ts +2 -1
- package/dist/objects.js +4 -1
- package/dist/read.cjs +43 -4
- package/dist/read.d.cts +1 -1
- package/dist/read.d.ts +1 -1
- package/dist/read.js +43 -4
- package/dist/write.cjs +1 -1
- package/dist/write.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/crypto/md5.ts
|
|
3
|
+
const BLOCK_BYTES = 64;
|
|
4
|
+
const DIGEST_BYTES = 16;
|
|
5
|
+
const ROUNDS = 64;
|
|
6
|
+
const WORDS_PER_BLOCK = 16;
|
|
7
|
+
const T = new Uint32Array([
|
|
8
|
+
3614090360,
|
|
9
|
+
3905402710,
|
|
10
|
+
606105819,
|
|
11
|
+
3250441966,
|
|
12
|
+
4118548399,
|
|
13
|
+
1200080426,
|
|
14
|
+
2821735955,
|
|
15
|
+
4249261313,
|
|
16
|
+
1770035416,
|
|
17
|
+
2336552879,
|
|
18
|
+
4294925233,
|
|
19
|
+
2304563134,
|
|
20
|
+
1804603682,
|
|
21
|
+
4254626195,
|
|
22
|
+
2792965006,
|
|
23
|
+
1236535329,
|
|
24
|
+
4129170786,
|
|
25
|
+
3225465664,
|
|
26
|
+
643717713,
|
|
27
|
+
3921069994,
|
|
28
|
+
3593408605,
|
|
29
|
+
38016083,
|
|
30
|
+
3634488961,
|
|
31
|
+
3889429448,
|
|
32
|
+
568446438,
|
|
33
|
+
3275163606,
|
|
34
|
+
4107603335,
|
|
35
|
+
1163531501,
|
|
36
|
+
2850285829,
|
|
37
|
+
4243563512,
|
|
38
|
+
1735328473,
|
|
39
|
+
2368359562,
|
|
40
|
+
4294588738,
|
|
41
|
+
2272392833,
|
|
42
|
+
1839030562,
|
|
43
|
+
4259657740,
|
|
44
|
+
2763975236,
|
|
45
|
+
1272893353,
|
|
46
|
+
4139469664,
|
|
47
|
+
3200236656,
|
|
48
|
+
681279174,
|
|
49
|
+
3936430074,
|
|
50
|
+
3572445317,
|
|
51
|
+
76029189,
|
|
52
|
+
3654602809,
|
|
53
|
+
3873151461,
|
|
54
|
+
530742520,
|
|
55
|
+
3299628645,
|
|
56
|
+
4096336452,
|
|
57
|
+
1126891415,
|
|
58
|
+
2878612391,
|
|
59
|
+
4237533241,
|
|
60
|
+
1700485571,
|
|
61
|
+
2399980690,
|
|
62
|
+
4293915773,
|
|
63
|
+
2240044497,
|
|
64
|
+
1873313359,
|
|
65
|
+
4264355552,
|
|
66
|
+
2734768916,
|
|
67
|
+
1309151649,
|
|
68
|
+
4149444226,
|
|
69
|
+
3174756917,
|
|
70
|
+
718787259,
|
|
71
|
+
3951481745
|
|
72
|
+
]);
|
|
73
|
+
const SHIFT = [
|
|
74
|
+
7,
|
|
75
|
+
12,
|
|
76
|
+
17,
|
|
77
|
+
22,
|
|
78
|
+
7,
|
|
79
|
+
12,
|
|
80
|
+
17,
|
|
81
|
+
22,
|
|
82
|
+
7,
|
|
83
|
+
12,
|
|
84
|
+
17,
|
|
85
|
+
22,
|
|
86
|
+
7,
|
|
87
|
+
12,
|
|
88
|
+
17,
|
|
89
|
+
22,
|
|
90
|
+
5,
|
|
91
|
+
9,
|
|
92
|
+
14,
|
|
93
|
+
20,
|
|
94
|
+
5,
|
|
95
|
+
9,
|
|
96
|
+
14,
|
|
97
|
+
20,
|
|
98
|
+
5,
|
|
99
|
+
9,
|
|
100
|
+
14,
|
|
101
|
+
20,
|
|
102
|
+
5,
|
|
103
|
+
9,
|
|
104
|
+
14,
|
|
105
|
+
20,
|
|
106
|
+
4,
|
|
107
|
+
11,
|
|
108
|
+
16,
|
|
109
|
+
23,
|
|
110
|
+
4,
|
|
111
|
+
11,
|
|
112
|
+
16,
|
|
113
|
+
23,
|
|
114
|
+
4,
|
|
115
|
+
11,
|
|
116
|
+
16,
|
|
117
|
+
23,
|
|
118
|
+
4,
|
|
119
|
+
11,
|
|
120
|
+
16,
|
|
121
|
+
23,
|
|
122
|
+
6,
|
|
123
|
+
10,
|
|
124
|
+
15,
|
|
125
|
+
21,
|
|
126
|
+
6,
|
|
127
|
+
10,
|
|
128
|
+
15,
|
|
129
|
+
21,
|
|
130
|
+
6,
|
|
131
|
+
10,
|
|
132
|
+
15,
|
|
133
|
+
21,
|
|
134
|
+
6,
|
|
135
|
+
10,
|
|
136
|
+
15,
|
|
137
|
+
21
|
|
138
|
+
];
|
|
139
|
+
const INITIAL_STATE = [
|
|
140
|
+
1732584193,
|
|
141
|
+
4023233417,
|
|
142
|
+
2562383102,
|
|
143
|
+
271733878
|
|
144
|
+
];
|
|
145
|
+
function rotl32(value, bits) {
|
|
146
|
+
return (value << bits | value >>> 32 - bits) >>> 0;
|
|
147
|
+
}
|
|
148
|
+
function padMessage(bytes) {
|
|
149
|
+
const paddedLength = (Math.floor((bytes.length + 8) / BLOCK_BYTES) + 1) * BLOCK_BYTES;
|
|
150
|
+
const padded = new Uint8Array(paddedLength);
|
|
151
|
+
padded.set(bytes);
|
|
152
|
+
padded[bytes.length] = 128;
|
|
153
|
+
const bitLength = bytes.length * 8;
|
|
154
|
+
let low = bitLength % 4294967296;
|
|
155
|
+
let high = Math.floor(bitLength / 4294967296);
|
|
156
|
+
for (let i = 0; i < 4; i++) {
|
|
157
|
+
padded[paddedLength - 8 + i] = low & 255;
|
|
158
|
+
low = Math.floor(low / 256);
|
|
159
|
+
padded[paddedLength - 4 + i] = high & 255;
|
|
160
|
+
high = Math.floor(high / 256);
|
|
161
|
+
}
|
|
162
|
+
return padded;
|
|
163
|
+
}
|
|
164
|
+
function md5(bytes) {
|
|
165
|
+
const padded = padMessage(bytes);
|
|
166
|
+
const state = Int32Array.from(INITIAL_STATE);
|
|
167
|
+
const block = new Uint32Array(WORDS_PER_BLOCK);
|
|
168
|
+
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) {
|
|
169
|
+
for (let i = 0; i < WORDS_PER_BLOCK; i++) {
|
|
170
|
+
const at = offset + i * 4;
|
|
171
|
+
block[i] = (padded[at] | padded[at + 1] << 8 | padded[at + 2] << 16 | padded[at + 3] << 24) >>> 0;
|
|
172
|
+
}
|
|
173
|
+
let a = state[0];
|
|
174
|
+
let b = state[1];
|
|
175
|
+
let c = state[2];
|
|
176
|
+
let d = state[3];
|
|
177
|
+
for (let i = 0; i < ROUNDS; i++) {
|
|
178
|
+
let f;
|
|
179
|
+
let g;
|
|
180
|
+
if (i < 16) {
|
|
181
|
+
f = b & c | ~b & d;
|
|
182
|
+
g = i;
|
|
183
|
+
} else if (i < 32) {
|
|
184
|
+
f = d & b | ~d & c;
|
|
185
|
+
g = (5 * i + 1) % WORDS_PER_BLOCK;
|
|
186
|
+
} else if (i < 48) {
|
|
187
|
+
f = b ^ c ^ d;
|
|
188
|
+
g = (3 * i + 5) % WORDS_PER_BLOCK;
|
|
189
|
+
} else {
|
|
190
|
+
f = c ^ (b | ~d);
|
|
191
|
+
g = 7 * i % WORDS_PER_BLOCK;
|
|
192
|
+
}
|
|
193
|
+
const rotated = rotl32(a + (f >>> 0) + T[i] + block[g] >>> 0, SHIFT[i]);
|
|
194
|
+
a = d;
|
|
195
|
+
d = c;
|
|
196
|
+
c = b;
|
|
197
|
+
b = b + rotated >>> 0;
|
|
198
|
+
}
|
|
199
|
+
state[0] = state[0] + a | 0;
|
|
200
|
+
state[1] = state[1] + b | 0;
|
|
201
|
+
state[2] = state[2] + c | 0;
|
|
202
|
+
state[3] = state[3] + d | 0;
|
|
203
|
+
}
|
|
204
|
+
const digest = new Uint8Array(DIGEST_BYTES);
|
|
205
|
+
for (let i = 0; i < state.length; i++) {
|
|
206
|
+
const word = state[i];
|
|
207
|
+
digest[i * 4] = word & 255;
|
|
208
|
+
digest[i * 4 + 1] = word >>> 8 & 255;
|
|
209
|
+
digest[i * 4 + 2] = word >>> 16 & 255;
|
|
210
|
+
digest[i * 4 + 3] = word >>> 24 & 255;
|
|
211
|
+
}
|
|
212
|
+
return digest;
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
exports.md5 = md5;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
//#region src/crypto/md5.ts
|
|
2
|
+
const BLOCK_BYTES = 64;
|
|
3
|
+
const DIGEST_BYTES = 16;
|
|
4
|
+
const ROUNDS = 64;
|
|
5
|
+
const WORDS_PER_BLOCK = 16;
|
|
6
|
+
const T = new Uint32Array([
|
|
7
|
+
3614090360,
|
|
8
|
+
3905402710,
|
|
9
|
+
606105819,
|
|
10
|
+
3250441966,
|
|
11
|
+
4118548399,
|
|
12
|
+
1200080426,
|
|
13
|
+
2821735955,
|
|
14
|
+
4249261313,
|
|
15
|
+
1770035416,
|
|
16
|
+
2336552879,
|
|
17
|
+
4294925233,
|
|
18
|
+
2304563134,
|
|
19
|
+
1804603682,
|
|
20
|
+
4254626195,
|
|
21
|
+
2792965006,
|
|
22
|
+
1236535329,
|
|
23
|
+
4129170786,
|
|
24
|
+
3225465664,
|
|
25
|
+
643717713,
|
|
26
|
+
3921069994,
|
|
27
|
+
3593408605,
|
|
28
|
+
38016083,
|
|
29
|
+
3634488961,
|
|
30
|
+
3889429448,
|
|
31
|
+
568446438,
|
|
32
|
+
3275163606,
|
|
33
|
+
4107603335,
|
|
34
|
+
1163531501,
|
|
35
|
+
2850285829,
|
|
36
|
+
4243563512,
|
|
37
|
+
1735328473,
|
|
38
|
+
2368359562,
|
|
39
|
+
4294588738,
|
|
40
|
+
2272392833,
|
|
41
|
+
1839030562,
|
|
42
|
+
4259657740,
|
|
43
|
+
2763975236,
|
|
44
|
+
1272893353,
|
|
45
|
+
4139469664,
|
|
46
|
+
3200236656,
|
|
47
|
+
681279174,
|
|
48
|
+
3936430074,
|
|
49
|
+
3572445317,
|
|
50
|
+
76029189,
|
|
51
|
+
3654602809,
|
|
52
|
+
3873151461,
|
|
53
|
+
530742520,
|
|
54
|
+
3299628645,
|
|
55
|
+
4096336452,
|
|
56
|
+
1126891415,
|
|
57
|
+
2878612391,
|
|
58
|
+
4237533241,
|
|
59
|
+
1700485571,
|
|
60
|
+
2399980690,
|
|
61
|
+
4293915773,
|
|
62
|
+
2240044497,
|
|
63
|
+
1873313359,
|
|
64
|
+
4264355552,
|
|
65
|
+
2734768916,
|
|
66
|
+
1309151649,
|
|
67
|
+
4149444226,
|
|
68
|
+
3174756917,
|
|
69
|
+
718787259,
|
|
70
|
+
3951481745
|
|
71
|
+
]);
|
|
72
|
+
const SHIFT = [
|
|
73
|
+
7,
|
|
74
|
+
12,
|
|
75
|
+
17,
|
|
76
|
+
22,
|
|
77
|
+
7,
|
|
78
|
+
12,
|
|
79
|
+
17,
|
|
80
|
+
22,
|
|
81
|
+
7,
|
|
82
|
+
12,
|
|
83
|
+
17,
|
|
84
|
+
22,
|
|
85
|
+
7,
|
|
86
|
+
12,
|
|
87
|
+
17,
|
|
88
|
+
22,
|
|
89
|
+
5,
|
|
90
|
+
9,
|
|
91
|
+
14,
|
|
92
|
+
20,
|
|
93
|
+
5,
|
|
94
|
+
9,
|
|
95
|
+
14,
|
|
96
|
+
20,
|
|
97
|
+
5,
|
|
98
|
+
9,
|
|
99
|
+
14,
|
|
100
|
+
20,
|
|
101
|
+
5,
|
|
102
|
+
9,
|
|
103
|
+
14,
|
|
104
|
+
20,
|
|
105
|
+
4,
|
|
106
|
+
11,
|
|
107
|
+
16,
|
|
108
|
+
23,
|
|
109
|
+
4,
|
|
110
|
+
11,
|
|
111
|
+
16,
|
|
112
|
+
23,
|
|
113
|
+
4,
|
|
114
|
+
11,
|
|
115
|
+
16,
|
|
116
|
+
23,
|
|
117
|
+
4,
|
|
118
|
+
11,
|
|
119
|
+
16,
|
|
120
|
+
23,
|
|
121
|
+
6,
|
|
122
|
+
10,
|
|
123
|
+
15,
|
|
124
|
+
21,
|
|
125
|
+
6,
|
|
126
|
+
10,
|
|
127
|
+
15,
|
|
128
|
+
21,
|
|
129
|
+
6,
|
|
130
|
+
10,
|
|
131
|
+
15,
|
|
132
|
+
21,
|
|
133
|
+
6,
|
|
134
|
+
10,
|
|
135
|
+
15,
|
|
136
|
+
21
|
|
137
|
+
];
|
|
138
|
+
const INITIAL_STATE = [
|
|
139
|
+
1732584193,
|
|
140
|
+
4023233417,
|
|
141
|
+
2562383102,
|
|
142
|
+
271733878
|
|
143
|
+
];
|
|
144
|
+
function rotl32(value, bits) {
|
|
145
|
+
return (value << bits | value >>> 32 - bits) >>> 0;
|
|
146
|
+
}
|
|
147
|
+
function padMessage(bytes) {
|
|
148
|
+
const paddedLength = (Math.floor((bytes.length + 8) / BLOCK_BYTES) + 1) * BLOCK_BYTES;
|
|
149
|
+
const padded = new Uint8Array(paddedLength);
|
|
150
|
+
padded.set(bytes);
|
|
151
|
+
padded[bytes.length] = 128;
|
|
152
|
+
const bitLength = bytes.length * 8;
|
|
153
|
+
let low = bitLength % 4294967296;
|
|
154
|
+
let high = Math.floor(bitLength / 4294967296);
|
|
155
|
+
for (let i = 0; i < 4; i++) {
|
|
156
|
+
padded[paddedLength - 8 + i] = low & 255;
|
|
157
|
+
low = Math.floor(low / 256);
|
|
158
|
+
padded[paddedLength - 4 + i] = high & 255;
|
|
159
|
+
high = Math.floor(high / 256);
|
|
160
|
+
}
|
|
161
|
+
return padded;
|
|
162
|
+
}
|
|
163
|
+
function md5(bytes) {
|
|
164
|
+
const padded = padMessage(bytes);
|
|
165
|
+
const state = Int32Array.from(INITIAL_STATE);
|
|
166
|
+
const block = new Uint32Array(WORDS_PER_BLOCK);
|
|
167
|
+
for (let offset = 0; offset < padded.length; offset += BLOCK_BYTES) {
|
|
168
|
+
for (let i = 0; i < WORDS_PER_BLOCK; i++) {
|
|
169
|
+
const at = offset + i * 4;
|
|
170
|
+
block[i] = (padded[at] | padded[at + 1] << 8 | padded[at + 2] << 16 | padded[at + 3] << 24) >>> 0;
|
|
171
|
+
}
|
|
172
|
+
let a = state[0];
|
|
173
|
+
let b = state[1];
|
|
174
|
+
let c = state[2];
|
|
175
|
+
let d = state[3];
|
|
176
|
+
for (let i = 0; i < ROUNDS; i++) {
|
|
177
|
+
let f;
|
|
178
|
+
let g;
|
|
179
|
+
if (i < 16) {
|
|
180
|
+
f = b & c | ~b & d;
|
|
181
|
+
g = i;
|
|
182
|
+
} else if (i < 32) {
|
|
183
|
+
f = d & b | ~d & c;
|
|
184
|
+
g = (5 * i + 1) % WORDS_PER_BLOCK;
|
|
185
|
+
} else if (i < 48) {
|
|
186
|
+
f = b ^ c ^ d;
|
|
187
|
+
g = (3 * i + 5) % WORDS_PER_BLOCK;
|
|
188
|
+
} else {
|
|
189
|
+
f = c ^ (b | ~d);
|
|
190
|
+
g = 7 * i % WORDS_PER_BLOCK;
|
|
191
|
+
}
|
|
192
|
+
const rotated = rotl32(a + (f >>> 0) + T[i] + block[g] >>> 0, SHIFT[i]);
|
|
193
|
+
a = d;
|
|
194
|
+
d = c;
|
|
195
|
+
c = b;
|
|
196
|
+
b = b + rotated >>> 0;
|
|
197
|
+
}
|
|
198
|
+
state[0] = state[0] + a | 0;
|
|
199
|
+
state[1] = state[1] + b | 0;
|
|
200
|
+
state[2] = state[2] + c | 0;
|
|
201
|
+
state[3] = state[3] + d | 0;
|
|
202
|
+
}
|
|
203
|
+
const digest = new Uint8Array(DIGEST_BYTES);
|
|
204
|
+
for (let i = 0; i < state.length; i++) {
|
|
205
|
+
const word = state[i];
|
|
206
|
+
digest[i * 4] = word & 255;
|
|
207
|
+
digest[i * 4 + 1] = word >>> 8 & 255;
|
|
208
|
+
digest[i * 4 + 2] = word >>> 16 & 255;
|
|
209
|
+
digest[i * 4 + 3] = word >>> 24 & 255;
|
|
210
|
+
}
|
|
211
|
+
return digest;
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
export { md5 };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/crypto/rc4.ts
|
|
3
|
+
const STATE_SIZE = 256;
|
|
4
|
+
function rc4(key, data) {
|
|
5
|
+
const state = new Uint8Array(STATE_SIZE);
|
|
6
|
+
for (let i = 0; i < STATE_SIZE; i++) state[i] = i;
|
|
7
|
+
if (key.length === 0) return Uint8Array.from(data);
|
|
8
|
+
let j = 0;
|
|
9
|
+
for (let i = 0; i < STATE_SIZE; i++) {
|
|
10
|
+
j = j + state[i] + key[i % key.length] & 255;
|
|
11
|
+
const swap = state[i];
|
|
12
|
+
state[i] = state[j];
|
|
13
|
+
state[j] = swap;
|
|
14
|
+
}
|
|
15
|
+
const out = new Uint8Array(data.length);
|
|
16
|
+
let x = 0;
|
|
17
|
+
let y = 0;
|
|
18
|
+
for (let n = 0; n < data.length; n++) {
|
|
19
|
+
x = x + 1 & 255;
|
|
20
|
+
y = y + state[x] & 255;
|
|
21
|
+
const swap = state[x];
|
|
22
|
+
state[x] = state[y];
|
|
23
|
+
state[y] = swap;
|
|
24
|
+
out[n] = data[n] ^ state[state[x] + state[y] & 255];
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.rc4 = rc4;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/crypto/rc4.ts
|
|
2
|
+
const STATE_SIZE = 256;
|
|
3
|
+
function rc4(key, data) {
|
|
4
|
+
const state = new Uint8Array(STATE_SIZE);
|
|
5
|
+
for (let i = 0; i < STATE_SIZE; i++) state[i] = i;
|
|
6
|
+
if (key.length === 0) return Uint8Array.from(data);
|
|
7
|
+
let j = 0;
|
|
8
|
+
for (let i = 0; i < STATE_SIZE; i++) {
|
|
9
|
+
j = j + state[i] + key[i % key.length] & 255;
|
|
10
|
+
const swap = state[i];
|
|
11
|
+
state[i] = state[j];
|
|
12
|
+
state[j] = swap;
|
|
13
|
+
}
|
|
14
|
+
const out = new Uint8Array(data.length);
|
|
15
|
+
let x = 0;
|
|
16
|
+
let y = 0;
|
|
17
|
+
for (let n = 0; n < data.length; n++) {
|
|
18
|
+
x = x + 1 & 255;
|
|
19
|
+
y = y + state[x] & 255;
|
|
20
|
+
const swap = state[x];
|
|
21
|
+
state[x] = state[y];
|
|
22
|
+
state[y] = swap;
|
|
23
|
+
out[n] = data[n] ^ state[state[x] + state[y] & 255];
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { rc4 };
|