From 0755a26783f2e13eb8a75c51c82410919884611c Mon Sep 17 00:00:00 2001 From: Valentin Silyutin Date: Tue, 23 Sep 2025 17:01:01 +0400 Subject: [PATCH] Remove sha256() --- index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 717f8b3..05eccf7 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,5 @@ /* eslint-disable unicorn/no-null */ -const sha256 = async (str) => { - const buf = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(str)); - return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, '0')).join(''); -}; - const getCanvasFingerprint = async () => { try { const canvas = document.createElement('canvas'); @@ -18,7 +13,7 @@ const getCanvasFingerprint = async () => { ctx.fillRect(0, 0, 50, 30); ctx.fillStyle = '#069'; ctx.fillText('fingerprint123', 2, 2); - return await sha256(canvas.toDataURL()); + return canvas.toDataURL(); } catch { return null; } @@ -46,7 +41,7 @@ const getWebGLFingerprint = async () => { stencilBits: gl.getParameter(gl.STENCIL_BITS), extensions: gl.getSupportedExtensions(), }; - return { hash: await sha256(JSON.stringify(props)), props }; + return props; } catch { return null; } @@ -68,7 +63,7 @@ const getAudioFingerprint = async () => { let sum = 0; const data = buf.getChannelData(0); for (let i = 0; i < data.length; i += 100) sum += Math.abs(data[i]); - return await sha256(String(sum)); + return sum; } catch { return null; } @@ -91,7 +86,7 @@ const getMathFingerprint = async () => { toExp: (123_456_789).toExponential(20), oneDivNegZero: 1 / -0, }; - return await sha256(JSON.stringify(values)); + return values; } catch { return null; }