Question about decode() |
[eluser]shinee[/eluser]
Hi, I have encoded one column called 'x' in a table. so far so good now I am retriving the table and passing the resource called $result to the controller, I want to decode column 'x' in the model function. How can I do it?
[eluser]shinee[/eluser]
like this: $msg=$input['password']; $input['password']=$this->encrypt->encode($msg);
[eluser]JoostV[/eluser]
That's in the manual, Shinee $this->encrypt->decode($encrypted_string); http://ellislab.com/codeigniter/user-gui...ption.html As you probably know, using $this->encrypt->encode() for passwords is a security risk. It is considered good practise to encrypt passwords in such a way that they cannot be decrypted. For instance, using sha1($msg); That way, if your database is stolen, the thiefs cannot retrieve the passwords.
[eluser]shinee[/eluser]
thanks, but the issue is that I don't know how to decode only one column in the table(resource) as I wrote above
[eluser]WanWizard[/eluser]
If your $resource is something returned by $query->result(), you can use Code: foreach ($resource as $key => $row)
[eluser]shinee[/eluser]
I was trying... I am new to php so please if you can explain: my resource come from this: $resource=$this->db->get_where('book',array('cat'=>$name,'email'=>$email)); now you wrote: foreach ($resource as $key => $row) { $resource[$key]->x = $this->encrypt->decode($row->x); } what is the index for this var? $resource=$resource x=the name of the column? $key & $row- shuold change??
[eluser]JoostV[/eluser]
I strongly advise you to read the Codeigniter userguide, especially if you're new to php Code: // Fetch some books
[eluser]shinee[/eluser]
Thanks, I did your example 1 on 1 I got this error Message: Trying to get property of non-object for this line: $result[$key]->password = $this->encrypt->decode($row->password); |
Welcome Guest, Not a member yet? Register Sign In |