ramesh
ramesh

Reputation: 4082

PHP-Codeigniter string encrypt and decrypt

In one web application in CI, they used to save COOKIE data as an encrypted form and retrieve by decrypting it. Its was working fine since "GoDaddy" blocked "base64_encode" due to some security reasons ( Don't know why ). This is the error which I got

A PHP Error was encountered
Severity: Warning
Message: base64_decode() has been disabled for security reasons
Filename: models/extras.php
Line Number: 196

My encrypt and decrypt code as follows. Is there any alternate method for doing the same with out "base64_encode" ?

function encodeString($str){
  for($i=0; $i<5;$i++)
  {
    $str=strrev(base64_encode($str)); //apply base64 first and then reverse the string
  }
  return $str;
}

function decodeString($str){
  for($i=0; $i<5;$i++)
  {
    $str=base64_decode(strrev($str)); //apply base64 first and then reverse the string}
   }
   return $str;
}

Thanks in advance

Upvotes: 0

Views: 1928

Answers (2)

channasmcs
channasmcs

Reputation: 1156

$data =array(           

 'password'    => md5($this->input->post('password')),

);

Upvotes: 0

Yogesh Suthar
Yogesh Suthar

Reputation: 30488

In order to eliminate this error message you need to do ONE of the following things:

  • Remove the base64_decode string from the disable_functions at php.ini* file
  • Ask your hosting provider to remove the string above if you don't have an access to the php.ini* file
  • Change hosting provider which allows the running of the base64_decode function.

Upvotes: 1

Related Questions