我想使用jsp页面本身使用sha256加密我的密码,使用javascript来保护各种安全攻击并将此加密密码发送到spring控制器。但是我无法生成散列字符串。 这是我的javascript代码。第一个警报即将到来但不是第二个。我是否需要为sha256包含任何jar或js才能工作?
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;
}
答案 0 :(得分:0)
默认情况下,javascript不包含SHA256您需要使用库,快速google search提供此页面http://www.movable-type.co.uk/scripts/sha256.html您还可以查看此问题Are there any SHA-256 javascript implementations that are generally considered trustworthy?