I'm using the jsSHA library to hash passwords but I'm getting different hashes, from the same string, everytime I run the script:
/* Password hash function */
var b = $("form#register"),
shaObj = new jsSHA('SHA-512', 'TEXT');
b.on('submit', function (e) {
e.preventDefault();
var p = $('#reg_pwd'),
q = $('#confirm_pwd');
shaObj.update(p.val());
var p_hash = shaObj.getHash("HEX");
//p.val(p_hash);
shaObj.update(q.val());
var q_hash = shaObj.getHash("HEX");
//q.val(q_hash);
$('p').html('String: ' + p.val() + '<br />Hash: ' + p_hash +
'<br />String: ' + q.val() + '<br />Hash: ' + q_hash)
//this.submit()
});
I've been able to reproduce this in a fiddle. Just type any text in one of the fields and press submit many times to see the hash changing. It's working fine in the demo page, though.
What is going on?