Function Updated 17 Oct 2026
sha256(text)
Returns the SHA-256 hash of the text as 64 upper-case hexadecimal characters. The text is encoded as UTF-8, numbers are converted the JavaScript way ("18.2"), and null or undefined is hashed as empty text.
A plain SHA-256 hash is not suitable for storing passwords — use a salted, slow hash such as PBKDF2 (crypto.subtle.deriveBits).
Parameters
textstringrequiredText to create hash for.
Returns
Upper-case hexadecimal string. null if not called with exactly one argument.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
let x = "test";
write(docly.sha256(x));
}#The template above produces this output:
9F86D081884C7D659A2FEAA0C55AD015A3BF4F1B2B0B822CD15D6C15B0F00A08