Skip to content

Commit

Permalink
Merge pull request #19496 from Snuffleupagus/shorter-#buildObjectKey
Browse files Browse the repository at this point in the history
Shorten the `CipherTransformFactory.prototype.#buildObjectKey` method
  • Loading branch information
Snuffleupagus authored Feb 15, 2025
2 parents 92ff26e + a722ca4 commit 8dec353
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 8dec353

Please sign in to comment.