问题背景
在SSM项目中,html页面需要将用户登录信息加密后传至后台进行验证。传输格式为一个加密过的json串,其中包括所要用的用户名、密码等信息。
var json = {
"userName":userName,
"passWord":enPassWord,
"identifyingCode":secureCode
}
传输时需要将该json串进行加密并传输,下面是加密和解密过程
//加密
var cipherText = AESEnc(aesKey, json);
//解密
var plainText = AESDec(aesKey, cipherText);
在加密后便用ajax进行请求
$.ajax({
type: 'POST',
url: 'http://localhost:8080/login',
data: {
requestData: cipherText,
encryptKey: encryptKey
},
dataType: 'json',
success: function (data) {
console.log(data);
if (data.msg=="成功") {
console.log("in")
changeCaptcha();
window.location.href="http://localho