From 4501dd6c173509deb5e35295199386ae1bbaeb37 Mon Sep 17 00:00:00 2001 From: src48597962 <48597962@qq.com> Date: Tue, 7 Mar 2023 09:33:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'test.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index b2392d13..0edc7443 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ function sha256(str) { - const data = new Uint8Array([...str].map(c => c.charCodeAt(0))); + const data = new Uint8Array(Array.from(str, c => c.charCodeAt(0))); return crypto.subtle.digest('SHA-256', data).then(hashBuffer => { const hashArray = Array.from(new Uint8Array(hashBuffer)); const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');