async function hash(str, iterations = 1000) {
//Gotta love that crypto API
const buf = await crypto.subtle.digest(
"SHA-256",
new TextEncoder("utf-8").encode(str)
);
//One liner from stackoverflow
let result = Array.prototype.map
.call(new Uint8Array(buf), (x) => ("00" + x.toString(16)).slice(-2))
.join("");
if (iterations === 0) {
return result;
} else {
//Recusive function for multiple iterations
return await hash(result, iterations - 1);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter