2013-04-15 259 views
0

在CI中的一個Web應用程序中,它們用於將COOKIE數據保存爲加密形式,並通過解密進行檢索。由於某些安全原因(不知道爲什麼),「GoDaddy」阻止了「base64_encode」,它工作正常。這是我得到的錯誤PHP-Codeigniter字符串加密和解密

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

我的加密和解密代碼如下。有沒有其他的方法可以用「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; 
} 

在此先感謝

+1

Wat?什麼原因可能會導致禁用這樣一個良性但至關重要的功能? – deceze

+1

@ramesh您必須要求您的託管服務提供商啓用這些功能或更改您的託管服務提供商。它依賴於你。 –

+0

是的..我要求託管服務提供商的「GoDaddy」......他們說他們不能接受「base64_encode」,我已經購買了服務器2年,還剩1.5年..他們不會退款 – ramesh

回答

1

爲了消除你需要做以下事情之一此錯誤消息:

  • 在php.ini中*文件中刪除從disable_functions選項的BASE64_DECODE串
  • 要求您的託管服務提供商刪除上面的字符串,如果您沒有訪問php.ini文件
  • 更改託管服務提供商whi ch允許運行base64_decode函數。
-1
$data =array(   

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

);