在codeigniter中为网站网址创建高安全加密ID?

时间:2013-02-12 14:43:08

标签: codeigniter

控制器:

function verifyuser()
{
    $uri = $this->uri->uri_to_assoc(4);
    //print_r($uri);
    if( isset( $uri['id'] ) && $uri['id'] != '' )

            {
            $where = array();
                $where['roll_number'] = $uri['id']; 
$this->data['verification'] = $this->admin_model->verify($where);


        }
        else
        {
        $this->data['verification'] = array();

        }
    $this->data['content'] = 'admin/verification';
    $this->view($this->data);   
}

MODEL:

function verify($where='')

{
  $this->db->select('*');
$this->db->from( $this->db->dbprefix('members') );
if( !(empty( $where )) )
$this->db->where( $where );


$result = $this->db->get();
//echo $this->db->last_query();
    return $result->result();

}

www.example.com/user/admin/verify/的 345
 到
www.example.com/user/admin/verify/hgf_877%%%_ oi

像这样。

1 个答案:

答案 0 :(得分:0)

出于安全考虑,您可以使用PHP.net手册中定义的任何编码。但我更喜欢base64_encode和base64_decode。我正在使用我的应用程序编码comples字符串。

<?php
$temp = 345;
$res = base64_encode($temp);
echo $res;echo "<br>";
$result = base64_decode($res);
echo $result;
?>

您也可以在此link中找到小例子。