Newer
Older
import { getCrypto } from 'pkijs';
export const createDeviceHash = async (publicKey) => {
try {
const stringToEncode = publicKey + navigator.userAgent;
const crypto = getCrypto();
const buffer = new window.TextEncoder().encode(stringToEncode);
const hash = await crypto.digest({ name: "SHA-1" }, buffer);
return window.btoa(String.fromCharCode(...new Uint8Array(hash)));
} catch (error) {
console.warn(error); // eslint-disable-line no-console
}
};