Remove sha256()

This commit is contained in:
Valentin Silyutin
2025-09-23 17:01:01 +04:00
parent 8f548f66d5
commit 0755a26783

View File

@@ -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;
}