Skip to content
Snippets Groups Projects
appUtility.js 424 B
Newer Older
  • Learn to ignore specific revisions
  • 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
      }
    };