From 5c081211ebfbdc2adb3d1ead469486580a2d57f7 Mon Sep 17 00:00:00 2001 From: Markin Igor <markin.io210@gmail.com> Date: Sat, 26 Jan 2019 13:32:55 +0300 Subject: [PATCH] Fix bug with creation of device hash. --- javascript/src/utilities/appUtility.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/javascript/src/utilities/appUtility.js b/javascript/src/utilities/appUtility.js index 00beb25..66cfaf8 100644 --- a/javascript/src/utilities/appUtility.js +++ b/javascript/src/utilities/appUtility.js @@ -4,8 +4,9 @@ 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)); + 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 } -- GitLab