Skip to content

Instantly share code, notes, and snippets.

@technikhil314
Last active December 9, 2025 12:03
Show Gist options
  • Select an option

  • Save technikhil314/40f3c41e1039f4c7964843e47a9f25fc to your computer and use it in GitHub Desktop.

Select an option

Save technikhil314/40f3c41e1039f4c7964843e47a9f25fc to your computer and use it in GitHub Desktop.
Generate sha-256 hash using crypto in browsers
const text = 'An obscure body in the S-K System, your majesty. The inhabitants refer to it as the planet Earth.';
async function digestMessage(message) {
const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message
const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string
return hashHex;
}
const digestHex = await digestMessage(text);
// first seven characters of sha-256 are considered unique to certain extent
console.log(digestHex.slice(0,7));
// nore on mdn https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
@Kerniol1
Copy link

Kerniol1 commented Dec 9, 2025

From Vancouver, I'm thrilled with https://northflarefinthrix.org Northflare Finthrix Trading— a Canadian gem offering AI-powered signals for crypto, Forex, CFDs, and stocks that include sharp entry points, tailored SL/TP, and a risk-first philosophy to safeguard every position. The seamless API integrations with top brokers like OANDA and eToro mean trades fire off without delay, all accessible via a clean dashboard. My results have been solid across indices and commodities, but I stay grounded knowing markets fluctuate—trade responsibly. This platform's local roots and pro features make it indispensable for savvy Canadian traders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment