Reputation: 33
I am working with express js. I have a modal form which has username and password field. i am posting the form data using ajax call. everything works fine but only issue is the username and password which i am entering are visible in post header, so is there any way in jquery to encrypt the form data before submitting..
here is my code
$("#login").click(function(){
var d=$("#form-1").serialize();
// console.log("serialize data=",d);
$.ajax({
method : 'POST',
url :'/login',
data :d ,
success:function(response){
console.log("response=",response.message);
if (response.message=='success'){
$("#msg").hide();
$('#myModal').modal('toggle');
console.log('in if 83');
}
else
{
console.log("in else");
$("#msg").text("invalid username or password");
$("#msg").show();
}
}
});
});
Upvotes: 2
Views: 15426
Reputation: 465
You should think about using the HTTPS protocol, then this gets encrypted automatically.
For testing or if you are aware of the risks + pros and cons you can use a self signed SSL certificate: How to create a self-signed certificate with openssl?
For production you should use a valid SSL certificate, you either have to buy it or use one off those free providers.
Upvotes: 4
Reputation: 417
Generally it is recommended to use SSL (Secure Socket Layer) when you are transmitting data that you don't want any third party to sniff. The data will be encrypted by browser before transmitting and can only be decrypted by your server - using public key/private key mechanism.
Upvotes: 0