DO NOT USE, unless you're hashing SHA-256 for the game Starbound.
This package is only intended for hashing SHA-256 the way Starbound does it. Starbound's hashing algorithm has an error where strings of length 55 will use the wrong number of padding 0's when applying the padding at the end of the message.
npm install --save starbound-sha256
There are two methods, one for computing the hash of the input, and one for double-hashing it:
; // "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"sha256; // "d7914fe546b684688bb95f4f888a92dfc680603a75f23eb823658031fff766d9"
Input is either an array of bytes or a string. String are always interpreted as binary data; if you have a hex-encoded string of data to parse, first convert it to a binary string or array of bytes.
Output by default is a hexadecimal-encoded string. Other options are an array of bytes, or a binary-encoded string:
; // "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" <= Hex-encoded; default; // [44,242,77,186,95,176,163,14,38,232,59,42,197,185,226,158,27,22,30,92,31,167,66,94,115,4,51,98,147,139,152,36] <= Array of bytes; // ",òMº_°£&è;*Å¹â\§B^s3b$" <= Binary-encoded string
Unit tests are written in Mocha. To run the test suite, checkout the git repository, and from within the base folder run:
$ npm install --dev$ npm test
Most of the code from CryptoJS https://code.google.com/p/crypto-js/