• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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 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
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.