Skip to content

Instantly share code, notes, and snippets.

@cjc
Created October 16, 2010 08:19
Show Gist options
  • Save cjc/629576 to your computer and use it in GitHub Desktop.
Save cjc/629576 to your computer and use it in GitHub Desktop.
SHA256 tests
var crypto = require("crypto"),
assert = require("assert");
assert.equal(
'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
crypto.createHash("sha256").update("").digest("hex"))
assert.equal(
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad',
crypto.createHash("sha256").update("abc").digest("hex"))
assert.equal(
'f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650',
crypto.createHash("sha256").update("message digest").digest("hex"))
assert.equal(
'f30ceb2bb2829e79e4ca9753d35a8ecc00262d164cc077080295381cbd643f0d',
crypto.createHash("sha256").update("secure hash algorithm").digest("hex"))
assert.equal(
'6819d915c73f4d1e77e4e1b52d1fa0f9cf9beaead3939f15874bd988e2a23630',
crypto.createHash("sha256").update("SHA256 is considered to be safe").digest("hex"))
assert.equal(
'248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1',
crypto.createHash("sha256").update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq").digest("hex"))
assert.equal(
'f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342',
crypto.createHash("sha256").update("For this sample, this 63-byte string will be used as input data").digest("hex"))
assert.equal(
'ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8',
crypto.createHash("sha256").update("This is exactly 64 bytes long, not counting the terminating byte").digest("hex"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment