1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19450 from Snuffleupagus/crypto-CipherTransform-iv-getRandomValues

Use `crypto.getRandomValues` unconditionally in the `src/core/crypto.js` file
This commit is contained in:
Tim van der Meij 2025-02-09 12:53:27 +01:00 committed by GitHub
commit 1921aefccf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1397,13 +1397,7 @@ class CipherTransform {
// Generate an initialization vector
const iv = new Uint8Array(16);
if (typeof crypto !== "undefined") {
crypto.getRandomValues(iv);
} else {
for (let i = 0; i < 16; i++) {
iv[i] = Math.floor(256 * Math.random());
}
}
crypto.getRandomValues(iv);
let data = stringToBytes(s);
data = cipher.encrypt(data, iv);