CodeIgniter 3.1.3发送加密的URL变量偶尔不起作用

I am trying to pass an encrypted user_ID variable through url using the new CI encryption library, passing the variable into the controller and into the model to run a query based on the passed variable value. The problem is sometimes it is working and sometimes it is not. I set my encryption key by the instruction given in the user guide and i have load the library in the autoload:

$key = bin2hex($this->encryption->create_key(16));

and setting the key into config.php:

$config['encryption_key'] = bin2hex('some_bin2hex_numbers_and_letters');

View (getting the variable to be pass):

<div class="col-sm-8">
    <?php foreach ($user_list as $row) {
        $ID = $row['user_ID'];
        $UID = $this->encryption->encrypt($ID);
        $username = $row['user_Username'];
        $firstname = $row['user_FirstName'];
        $lastname = $row['user_LastName']; 
    ?>

    <a href="<?php echo base_url()?>Admin/User?uid=<?php echo $UID;?>">
        <h2 style="font-family:'Comic Sans MS', cursive;\"> <?php echo $username." (".$firstname." ".$lastname.") </h2> <br />" ?>
    </a>

    <?php } ?>
</div>

Controller:

public function User() {
    $ID  = $this->input->get('uid');
    $UID = $this->encryption->decrypt($ID);
    $data['user'] = $this->Admin_model->getUserData($UID);
    $this->load->view('pages/admin/admin_header');  
    $this->load->view('pages/admin/admin_user_data', $data);    
    $this->load->view('templates/footer2'); 
}

model (to get the passed variable and return a row):

public function getUserData($UID) {
    $query = $this->db->query("SELECT * FROM `tbl_user` WHERE `tbl_user`.`user_ID`='$data'");
    $row = $query->row();
    return $row;
}

view admin_user_data (the view to display the result of passed variable):

<h1>
    <?php 
    echo "User ID: ".$user->user_ID."<br />";
    echo "Username: ".$user->user_Username."<br />";
    echo "First Name: ".$user->user_FirstName."<br />";
    echo "Last Name: ".$user->user_LastName."<br />";
    ?>
</h1>

Actually this method work for me.

For encryption

$this->load->library('encryption'); 

$this->encryption->initialize(
array(
       'cipher' => 'aes-256',
       'mode' => 'ctr',
       'key' => '4lWC8cegO92vhTRbiRy21sh90TwFz6DR' // A random key generated by visiting http://randomkeygen.com/
     )
);   

$enc_id = $this->encryption->encrypt($id);

For decryption

    $this->load->library('encryption'); 

    $this->encryption->initialize(
    array(
            'cipher' => 'aes-256',
            'mode' => 'ctr',
            'key' => '4lWC8cegO92vhTRbiRy21sh90TwFz6DR' // Same key you used for encryption
        )
    );  

    $dec_id = $this->encryption->decrypt($enc_id);

The above approach work for me every time. Please comment below if you encountered any problem.