如何加密codeigniter的url参数没有不允许的字符? [英] how to encrypt url parameters in codeigniter without disallowed characters?

查看:240
本文介绍了如何加密codeigniter的url参数没有不允许的字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一页上加密我们的网址参数,并为了安全起见,在其他网页上解密。当我尝试这样,然后不允许的字符错误发生。我也不想设置$ config ['permitted_uri_chars']。根据这个。

i want to encrypt our url parameters on one page and decrypt on other page for security reason. when i try this then disallowed character error occurs. also i do not want to set $config['permitted_uri_chars']. according to this.

请给我解决方案,我能够用url加密参数 -

please give me solution that i can able to encrypt parameters with url like-

wwww.domain.com/controller_name/method_name/parameter1/parameter2

和我使用喜欢加密url -

and i am using like for encrypt url-

<a href="<?php echo site_url('C_Name/M_Name/'.$this->encrypt->encode($id)); ?>">Link</a>

我正在使用like解密url -

and i am using like for decrypt url-

echo $this->encrypt->decode($id)


b $ b

其他问题是其值被随机更改。

other issue is that its value is being changed randomly.

请让我明白如何这样做。

Please make me understand that how to do this.

感谢。

推荐答案

STEP 1
请创建一个hepler函数帮助文件夹

STEP 1 Please create a hepler function helper folder

  function encode_url($string, $key="", $url_safe=TRUE)
{
    if($key==null || $key=="")
    {
        $key="tyz_mydefaulturlencryption";
    }
      $CI =& get_instance();
    $ret = $CI->encrypt->encode($string, $key);

    if ($url_safe)
    {
        $ret = strtr(
                $ret,
                array(
                    '+' => '.',
                    '=' => '-',
                    '/' => '~'
                )
            );
    }

    return $ret;
}
  function decode_url($string, $key="")
{
     if($key==null || $key=="")
    {
        $key="tyz_mydefaulturlencryption";
    }
        $CI =& get_instance();
    $string = strtr(
            $string,
            array(
                '.' => '+',
                '-' => '=',
                '~' => '/'
            )
        );

    return $CI->encrypt->decode($string, $key);
}

STEP 2

在自动加载中分配此文件
$ autoload ['helper'] = array('url','form','url_encryption_helper');

STEP 2
Assign this file in autoload $autoload['helper'] = array('url','form','url_encryption_helper');

步骤3
调用函数encode_url in controller,model,view for encryption

STEP 3 Call function " encode_url " in controller , model , view for encryption

   $rr="rahul K A";
   $a= encode_url($rr); 

这篇关于如何加密codeigniter的url参数没有不允许的字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆