SHA 1/256/384/512 Hash Generator Using Web Crypto API - jQuery Hash

SHA 1/256/384/512 Hash Generator Using Web Crypto API - jQuery Hash
File Size: 6.38 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Hash.js is a small jQuery plugin used for generating SHA 1/256/384/512 hashes of any string you provide using the Web Crypto API.

See also:

How to use it:

1. Install & download the package.

# NPM
$ npm install jquery-hash --save

2. Include the Hash.js script after jQuery JavaScript library.

<script src="https://code.jquery.com/jquery-3.4.0.slim.min.js" 
        integrity="sha384-7WBfQYubrFpye+dGHEeA3fHaTy/wpTFhxdjxqvK04e4orV3z+X4XC4qOX3qnkVC6" 
        crossorigin="anonymous">
</script>
<script src="./dist/jq-hash.min.js"></script>

3. Or from the CDN.

<script src="https://code.jquery.com/jquery-3.4.0.slim.min.js" 
        integrity="sha384-7WBfQYubrFpye+dGHEeA3fHaTy/wpTFhxdjxqvK04e4orV3z+X4XC4qOX3qnkVC6" 
        crossorigin="anonymous">
</script>
<script src="https://unpkg.com/[email protected]/dist/jq-hash.min.js"></script>

4. Generate the SHA hash from a string you provide. Available parameters:

  • str: any string.
  • digest: the hash function to use (1/256/384/512)
  • enc: hex, base64, or Uint8
  • cb: callback function which can be used to return the generated hashes.
// $.hash(str, digest, enc, cb)
$.hash('jQueryScript', '256', 'hex',function(i){
  alert(i);
});

This awesome jQuery plugin is developed by angeal185. For more Advanced Usages, please check the demo page or visit the official website.