EasyJavaScriptTypeScript

SHA-256 Hash (crypto module)

Node.jsCryptoSecurity

Hash a string with SHA-256 using Node.js's built-in `crypto` module.

solve('hello')'2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824'

This module is Node.js-only (no browser equivalent without a polyfill).

const crypto = require('crypto');
crypto.createHash('sha256').update(data).digest('hex');

Sample tests

Test #1Empty string has fixed hash
Input: [""]
Output: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
Test #2NIST test vector "abc"
Input: ["abc"]
Output: "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
Test #3Classic pangram test vector
Input: ["The quick brown fox jumps over the lazy dog"]
Output: "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"
Test #4Hash of "hello"
Input: ["hello"]
Output: "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"