From 7919f4e84fdf0adf98e9083211a8e5430d29a195 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 9 Feb 2025 11:42:17 +0100 Subject: [PATCH] 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 --- src/core/crypto.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/crypto.js b/src/core/crypto.js index 1eee1e6fc..883c21d89 100644 --- a/src/core/crypto.js +++ b/src/core/crypto.js @@ -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);