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("utf-8").encode(stringToEncode);
return window.btoa(await crypto.digest({ name: "SHA-1" }, buffer));
} catch (error) {
console.warn(error); // eslint-disable-line no-console
}
};