Is it possible to encrypt http post requests?
I am using codeigniter’s encrypt class like so, however the post data does not seem to be encrypted?.
Is SSL the only way to encrypt such requests?
(function($){
var common = {
init: function(){
this.Forms();
},
Forms: function(){
var form = $('form),
formData = form.serialize(),
formUri = form.attr('action')
formBtn = form.find('button);
form.submit(function(){
$.ajax({
url: formUri,
data: '<?php $this->encrypt(' + formData + ');?>',
type: 'POST',
dataType: 'json',
success: function(callback){
console.log(callback);
formBtn.hide();
}
});
});
}
}
$(function(){
common.init();
});
})(jQuery.noConflict);
First off, you cannot have JAVASCRIPT mixed with PHP and expect to have PHP encrypt a JAVA variable.
data: '<?php $this->encrypt(' + formData + ');?>'PHP is done server side, and JS is client side, always keep that in mind.
2ndly you cannot have ENCRYPTION on the POST array (why?) because it is submitted from
client => serverand again you don’t control the clients side encryption. So that is a given that it WON’T work.That is why you have SSL, the clients communication is all tunneled and encrypted to your host. If you want security, the only way is to run your HTTP traffic over HTTPS (SSL)