我有加密/解密电子邮件的问题,我只是像这样发送邮件链接
http://www.domain.com/mycontroller/myfunction/McvBsce........etc
最后一段实际上是一个加密的电子邮件ID,当用户点击此链接时,我解密了这封电子邮件并更新了我的数据库中的stus。所有操作都正确。
问题:当这样的网址时
http://www.domain.com/mycontroller/myfunction/McvB/sce
它显示404错误,因为斜杠包含在生成的加密密钥中。如何在生成加密时忽略斜杠,这是我的主要问题,其余工作正常。
答案 0 :(得分:5)
您需要使用此类,在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);
}
}
积分转到codeigniter论坛,我从那里得到了它。