mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Merge pull request #19496 from Snuffleupagus/shorter-#buildObjectKey
Shorten the `CipherTransformFactory.prototype.#buildObjectKey` method
This commit is contained in:
commit
8dec353c7a
1 changed files with 4 additions and 6 deletions
|
@ -1595,12 +1595,10 @@ class CipherTransformFactory {
|
|||
}
|
||||
|
||||
#buildObjectKey(num, gen, encryptionKey, isAes = false) {
|
||||
const key = new Uint8Array(encryptionKey.length + 9);
|
||||
const n = encryptionKey.length;
|
||||
let i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
key[i] = encryptionKey[i];
|
||||
}
|
||||
const key = new Uint8Array(n + 9);
|
||||
key.set(encryptionKey);
|
||||
let i = n;
|
||||
key[i++] = num & 0xff;
|
||||
key[i++] = (num >> 8) & 0xff;
|
||||
key[i++] = (num >> 16) & 0xff;
|
||||
|
@ -1613,7 +1611,7 @@ class CipherTransformFactory {
|
|||
key[i++] = 0x54;
|
||||
}
|
||||
const hash = calculateMD5(key, 0, i);
|
||||
return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
|
||||
return hash.subarray(0, Math.min(n + 5, 16));
|
||||
}
|
||||
|
||||
#buildCipherConstructor(cf, name, num, gen, key) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue