rbs*_*ack 1 php encryption codeigniter urlencode urldecode
我有加密/解密电子邮件的问题,我只是发送这样的邮件链接
http://www.domain.com/mycontroller/myfunction/McvBsce........etc
Run Code Online (Sandbox Code Playgroud)
最后一段实际上是一个加密的电子邮件ID,当我点击此链接时,我解密了这封电子邮件并更新了我的数据库中的stus.所有操作都正确.
问题:当这样的网址时
http://www.domain.com/mycontroller/myfunction/McvB/sce
Run Code Online (Sandbox Code Playgroud)
它显示404错误,因为斜杠包含在生成的加密密钥中.如何在生成加密时忽略斜杠,这是我的主要问题,其余工作正常.
你需要使用这个类,在你的applicatio/libraries文件夹中包含这个文件,我遇到了同样的问题:
class MY_Encrypt extends CI_Encrypt
{
/**
* Encodes a string.
*
* @param string $string The string to encrypt.
* @param string $key[optional] The key to encrypt with.
* @param bool $url_safe[optional] Specifies whether or not the
* returned string should be url-safe.
* @return string
*/
function encode($string, $key="", $url_safe=TRUE)
{
$ret = parent::encode($string, $key);
if ($url_safe)
{
$ret = strtr(
$ret,
array(
'+' => '.',
'=' => '-',
'/' => '~'
)
);
}
return $ret;
}
/**
* Decodes the given string.
*
* @access public
* @param string $string The encrypted string to decrypt.
* @param string $key[optional] The key to use for decryption.
* @return string
*/
function decode($string, $key="")
{
$string = strtr(
$string,
array(
'.' => '+',
'-' => '=',
'~' => '/'
)
);
return parent::decode($string, $key);
}
}
Run Code Online (Sandbox Code Playgroud)
积分转到了codeigniter论坛,我从这里得到了这个.
| 归档时间: |
|
| 查看次数: |
2194 次 |
| 最近记录: |