1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use crypto.getRandomValues unconditionally in the src/core/crypto.js file

This functionality is now available in all browsers/environments that we support, please see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#browser_compatibility
This commit is contained in:
Jonas Jenwald 2025-02-09 11:42:17 +01:00
parent 72339dc561
commit 7919f4e84f

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);