Skip to content

Instantly share code, notes, and snippets.

@glynrob
Created October 20, 2013 16:08
Show Gist options
  • Save glynrob/7071600 to your computer and use it in GitHub Desktop.
Save glynrob/7071600 to your computer and use it in GitHub Desktop.
/* POLYCRYPT HASH */
function polycryptHash(){
document.getElementById("polypassword").innerHTML=password;
var polystring=util.str2abv(password);
var op=window.polycrypt.digest("SHA-256",polystring);
op.oncomplete=function(e){
var hex=util.abv2hex(e.target.result);
document.getElementById("polyhash").innerHTML=hex;
}
op.onerror=function(e){
console.log("error");
}
}
window.polycrypt.onalive=polycryptHash;
/* CRYPTOJS HASH */
var cryptohash = CryptoJS.SHA256(password);
document.getElementById("cryptopassword").innerHTML=password;
document.getElementById("cryptohash").innerHTML=cryptohash;
/* SJCL HASH */
var bitArray = sjcl.hash.sha256.hash(password);
var digest_sha256 = sjcl.codec.hex.fromBits(bitArray);
document.getElementById("sjclpassword").innerHTML=password;
document.getElementById("sjclhash").innerHTML=digest_sha256;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment