【发布时间】:2018-01-26 22:54:53
【问题描述】:
我正在尝试加密通过 ajax 以 json 格式发送的密码。加密逻辑在我的 server.js 中
如何传递来自 server.js 的加密响应。我可以加密,但我一直在传递这个加密的响应
server.js:
app.post('/mylink',function(request,reply){
var data = JSON.stringify(request.body.jsonblob);
var pwd = request.body.jsonblob.Password;
var cipher = crypto.createCipher(algorithm,password)
var crypted = cipher.update(pan,'utf8','hex')
crypted += cipher.final('hex');
console.log("crypted"+crypted);
reply.send(crypted);
});
在我的 html 页面中调用 ajax:
var json_data = JSON.stringify({
"jsonblob" : {
"Password": password
}
});
$.ajax({
url:"/mylink",
type: "post",
dataType: "json",
contentType: "application/json",
data: json_data,
success:function(response){
if(response.status === "success")
{
console.log(crypted);
}
},
error: function(jqXHR, textStatus, errorThtrown) {
console.log("error " +textStatus);
}
});
【问题讨论】:
-
使用 HTTPS,这将完全安全透明地发生吗?
-
如果你请求json,你需要用json响应。向客户端返回密码没有意义
-
感谢您的澄清
标签: javascript jquery html node.js ajax