From ee308587c3725c9f84c6cb93a705b18f872f1058 Mon Sep 17 00:00:00 2001 From: qwerty47 <7800041+qwerty47@user.noreply.gitee.com> Date: Thu, 17 Oct 2024 17:02:26 +0000 Subject: [PATCH] =?UTF-8?q?getRandomUint8Array=20=E6=94=B9=E7=94=A8=20cryp?= =?UTF-8?q?toFramework=20=E6=8F=90=E4=BE=9B=E7=9A=84=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E3=80=82=20Math.random()=20=E5=BA=95?= =?UTF-8?q?=E5=B1=82=E9=87=87=E7=94=A8=20xorshift64=20=E7=AE=97=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E5=BE=97=E7=9F=A5=E9=83=A8=E5=88=86=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E5=8F=AF=E9=A2=84=E6=B5=8B=E5=85=B6=E4=BD=99=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此处是 crypto 相关实现,应替换为密码学安全的随机数实现,例如 cryptoFramework 中最终调用 openssl 派生的随机数。 Signed-off-by: qwerty47 <7800041+qwerty47@user.noreply.gitee.com> --- harmony_utils/src/main/ets/crypto/CryptoHelper.ets | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/harmony_utils/src/main/ets/crypto/CryptoHelper.ets b/harmony_utils/src/main/ets/crypto/CryptoHelper.ets index 3e29dde..c3f08c2 100644 --- a/harmony_utils/src/main/ets/crypto/CryptoHelper.ets +++ b/harmony_utils/src/main/ets/crypto/CryptoHelper.ets @@ -140,11 +140,7 @@ export class CryptoHelper { * @returns */ static getRandomUint8Array(size: number): Uint8Array { - let randArray = new Array(); - for (let i = 0; i < size; i++) { - randArray.push(Math.floor(Math.random() * 256)); - } - return new Uint8Array(randArray); + return cryptoFramework.createRandom().generateRandomSync(size).data; } -- Gitee