JavaScript sha256 sample code
class Sha256Hash {
static async encode(input) {
const encoder = new TextEncoder();
const data = encoder.encode(input);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
}
}
const input = "1234567";
Sha256Hash.encode(input).then(encoded => {
console.log("Encoded:", encoded);
});