Share feedback, ideas and get community help

Updated 7 months ago

Transform variables into Hash via server (without executing on the client)

Hello,

With the following code (as shown below), I managed to transform a variable into a hash. However, this code only works on the client side. I would like to know a way to execute it on the server, without relying on the client. Thank you very much.


async function sha256(message) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
return hashHex;
}

const hashTel = await sha256("{{phone}}");
return hashTel;
Attachment
image.png
Add a reply
Sign up and join the conversation on Discord