Skip to content
Snippets Groups Projects

138 information for devices clients

Merged Igor Markin requested to merge 138-information-for-devices-clients into master
1 file
+ 3
2
Compare changes
  • Side-by-side
  • Inline
@@ -4,8 +4,9 @@ export const createDeviceHash = async (publicKey) => {
@@ -4,8 +4,9 @@ export const createDeviceHash = async (publicKey) => {
try {
try {
const stringToEncode = publicKey + navigator.userAgent;
const stringToEncode = publicKey + navigator.userAgent;
const crypto = getCrypto();
const crypto = getCrypto();
const buffer = new window.TextEncoder("utf-8").encode(stringToEncode);
const buffer = new window.TextEncoder().encode(stringToEncode);
return window.btoa(await crypto.digest({ name: "SHA-1" }, buffer));
const hash = await crypto.digest({ name: "SHA-1" }, buffer);
 
return window.btoa(String.fromCharCode(...new Uint8Array(hash)));
} catch (error) {
} catch (error) {
console.warn(error); // eslint-disable-line no-console
console.warn(error); // eslint-disable-line no-console
}
}
Loading