开发者

Http Post Encryption, Codeigniter enc class? Possible?

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->encry开发者_开发百科pt(' + 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 => server and 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)


What you can do, if you have not the possibility to use ssl, use jcryption

But keep in mind: It's not a replacement for ssl, it helps you maybe a little bit ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜