diff options
author | Brian Turek <brian.turek@gmail.com> | 2013-08-23 13:14:15 -0700 |
---|---|---|
committer | Brian Turek <brian.turek@gmail.com> | 2013-08-23 13:14:15 -0700 |
commit | bda2a07d539ea88cb82f490c1305a521eb917ff1 (patch) | |
tree | 7c86d59d2b871391aad10b577fa7e8cb7ca63343 | |
parent | 415356d07da4148735ec98f9bd41324effe65653 (diff) | |
parent | 6a789450aec32dd3d29c96b50fa0cc671fa439ad (diff) | |
download | jsSHA-bda2a07d539ea88cb82f490c1305a521eb917ff1.zip jsSHA-bda2a07d539ea88cb82f490c1305a521eb917ff1.tar.gz jsSHA-bda2a07d539ea88cb82f490c1305a521eb917ff1.tar.bz2 |
Merge pull request #11 from wesbos/master
Improved README / docs
-rwxr-xr-x | README.md (renamed from README) | 42 |
1 files changed, 27 insertions, 15 deletions
@@ -1,4 +1,5 @@ -jsSHA - A JavaScript implementation of the complete Secure Hash Standard family +# jsSHA +A JavaScript implementation of the complete Secure Hash Standard family (SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512) as well as HMAC by Brian Turek @@ -7,6 +8,7 @@ About jsSHA is a javaScript implementation of the complete Secure Hash Algorithm family as defined by FIPS PUB 180-2 (http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf). + It also includes the HMAC algorithm with SHA support as defined by FIPS PUB 198-1 (http://csrc.nist.gov/publications/fips/fips198-1/FIPS-198-1_final.pdf) @@ -20,29 +22,36 @@ on 25 February 2004 so it was also included in this package. Files ------------------------- -src/sha_dev.js +**src/sha_dev.js** + A commented implementation of the entire SHA family of hashes. Not to be used in production. -src/sha.js +**src/sha.js** + A Google Closure Compiler optimized version of the entire library -src/sha1.js +**src/sha1.js** + A Google Closure Compiler optimized version the library with non SHA-1 functionality removed -src/sha256.js +**src/sha256.js** + A Google Closure Compiler optimized version the library with non SHA-224/SHA-256 functionality removed -src/sha512.js +**src/sha512.js** + A Google Closure Compiler optimized version the library with non SHA-384/SHA-512 functionality removed -test/test.html +**test/test.html** + A test page that calculates various hashes and has their correct values -build/make-release +**build/make-release** + A Bash script that runs the various Google Closure Compiler commands to build a release @@ -50,18 +59,21 @@ Usage ------------------------- Include the desired JavaScript file (sha.js, sha1.js, sha256.js, or sha512.js) in your header (sha.js used below): -<script type="text/javascript" src="/path/to/sha.js"></script> + + <script type="text/javascript" src="/path/to/sha.js"></script> Instantiate a new jsSHA object with your string to be hashed and its format (HEX or TEXT) as the parameters. Then, call getHash with the desired hash variant (SHA-1, SHA-224, SHA-256, SHA-384, or SHA-512) and output type -(HEX or B64). In the example below, "This is a Test" and "SHA-512" were used +(HEX or B64). + +In the example below, "This is a Test" and "SHA-512" were used as the string to be hashed and variant respectively. Also, the HMAC using TEXT key "SecretKey" and hashing algorithm SHA-512 was calculated. -var shaObj = new jsSHA("This is a Test", "TEXT"); -var hash = shaObj.getHash("SHA-512", "HEX"); -var hmac = shaObj.getHMAC("SecretKey", "TEXT", "SHA-512", "HEX"); + var shaObj = new jsSHA("This is a Test", "TEXT"); + var hash = shaObj.getHash("SHA-512", "HEX"); + var hmac = shaObj.getHMAC("SecretKey", "TEXT", "SHA-512", "HEX"); The constructor takes an optional parameter, encoding, that specifies the encoding used to encode TEXT-type inputs. Valid options are "UTF8" and "UTF16" @@ -69,7 +81,7 @@ and it defaults to "UTF8" Both getHash and getHMAC also take an optional has list parameter, outputFormatOpts, that dictates some formatting options for the output. By -default, outputFormatOpts = {"outputUpper" : false, "b64Pad" : "="}. These +default, `outputFormatOpts = {"outputUpper" : false, "b64Pad" : "="}`. These options are intelligently interpreted based upon the chosen output format. Compiling @@ -90,4 +102,4 @@ where <FLAG> is a bitwise OR of the following values: Contact Info ------------------------- -The project's website is located at http://caligatio.github.com/jsSHA/ +The project's website is located at [http://caligatio.github.com/jsSHA/](http://caligatio.github.com/jsSHA/) |