jssha256: SHA256 & HMAC-SHA256 in JavaScript

jssha256 is a compact JavaScript implementation of the SHA256 secure hash function. HMAC calculation is also available.

Example

The following code example computes the SHA256 hash value of the string 'abc'.

SHA256_init();
SHA256_write("abc");
digest = SHA256_finalize();  
digest_hex = array_to_hex_string(digest);

Get the same result by calling the shortcut function SHA256_hash:

digest_hex = SHA256_hash("abc");

In the following example the calculation of the HMAC of the string 'abc' using the key 'secret key' is shown.

HMAC_SHA256_init("secret key");
HMAC_SHA256_write("abc");
mac = HMAC_SHA256_finalize();
mac_hex = array_to_hex_string(mac);

Again, the same can be done more conveniently:

mac_hex = HMAC_SHA256_MAC("secret key", "abc");

Download

jssha256 is free software, written in 2006 by B. Poettering. The code is licensed under the GNU GPL. The well-functioning of the hashing & MACing routines has been verified with the test vectors given in FIPS-180-2, Appendix B, and IETF RFC 4231, respectively.

Download jssha256-0.1.tar.gz (SHA1: E2F82B29ADA536361CA07CC3375C2236F22F2CAA).
Or view the current version directly.

The code is well documented and the API trivial. Therefore there are no further docs at the moment.

New versions are announced via the freshmeat page.

Final notices

jsaes, ssss: Shamir's Secret Sharing Scheme and seccure are other crypto software projects by the same author.

If jssha256, jsaes, seccure or ssss are of value for you, please consider donating some money via .


The text of this page is licensed under the GNU General Public License. Copyright 2006 by B. Poettering (jssha256 AT point-at-infinity.org).
Last modified: Tue Mar 20 20:41:56 CET 2012