I want to encrypt my password using sha256 on jsp page itself using javascript to protect various security attacks and send this encrypted password to spring controller. But I am not able to get hashed string generated. This is my javascript code. First alert is coming but not the second one. Do i need to include any jar or js for sha256 to work?
document.getElementById('loginButton').onclick = function() {
var txt_string = document.getElementById('loginPassword').value; // gets data from input text
alert('normal password is' + txt_string);
// encrypts data and adds it in #strcrypt element
var hashedpassword = SHA256(txt_string);
alert('hashed password is' + hashedpassword);
return false;
}