Welcome Guest, Not a member yet? Register   Sign In
about Encryption Library
#1

Hello, I have 2 function for encode and decode.

So I upgrade php to php7.1 and I can not use encrypt old library.

now I try to using encryption new library.

and I get string / = + after encrypt because / it make can not pass string on url

Pls, I need you help.

PHP Code:
public function encode_me($string$key '') {
        
//$this->load->library('encrypt');
        //return rtrim(strtr(base64_encode($this->encrypt->mcrypt_encode($string, $this->encrypt->get_key($key))), '+/', '-_'), '=');

        
$this->load->library('encryption');
        return 
$this->encryption->encrypt($string);
    }

    public function 
decode_me($string$key '') {
        
//$this->load->library('encrypt');
        //return $this->encrypt->mcrypt_decode(base64_decode(str_pad(strtr($string, '-_', '+/'), strlen($string) % 4, '=', STR_PAD_RIGHT)), $this->encrypt->get_key($key));

        
$this->load->library('encryption');
        return 
$this->encryption->decrypt($string);
    } 
Reply
#2

OK now I solution this way if you better way pls tel me thank you

PHP Code:
public function encode_me($string$key '') {
        
$this->load->library('encryption');
        return 
rtrim(strtr(base64_encode$this->encryption->encrypt($string) ), '+/''-_'), '=');
    }

    public function 
decode_me($string$key '') {
        
$this->load->library('encryption');
        return 
$this->encryption->decryptbase64_decode(str_pad(strtr($string'-_''+/'), strlen($string) % 4'='STR_PAD_RIGHT)) );
    } 
Reply
#3

(This post was last modified: 03-12-2017, 06:46 AM by Narf.)

This is not a solution, it may corrupt the data.

Use rawurlencode()
Reply
#4

And on another note - if something's worth encrypting, it doesn't belong in a URL, so whatever you're doing it's deffinately wrong.
Reply
#5

(This post was last modified: 03-12-2017, 05:48 PM by seasenx6.)

Thank you so much Narf I will using rawurl.

I must to send some data on url and must important data so I will back to find better anothor way such as pass encryption data on $this->load->view()

Thank agian I will improve my seft thank you Narf.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB