On Thu, Nov 11, 2010 at 4:13 PM, laduree <[email protected]> wrote:
> I have some data coming from a form, and I'm trying to encrypt part of
> it and save it in a mysql db. Everything gets saved, except the
> encrypted field, which is empty when I look in the database.
>
> I'm new to CakePHP and wasn't successful googling for a solution,
> thanks for taking the time to read this.
>
> /*
>  * Encrypts and saves message
>  */
> function compose() {
>                if(!empty($this->data)) {
>
>                        $this->data['Message']['user_id'] = $this->Session-
>>read('Auth.User.id');
>
>                        // Encrypt message
>                        $security = new Security;
>
>                        $this->data['Message']['msg'] = 
> $security->cipher($this-
>>data['Message']['msg'],
>                                                                               
>                  Configure::read('Security.cipherSeed'));
>
>                        // Save message
>                        if($this->Message->save($this->data)){
>                                $this->Session->setFlash('Ok', 'flash_ok');
>                        } else {
>                                $this->Session->setFlash('Error');
>                        }
>                }
>        }
> }

Instead of instantiating Security, try:

$this->data['Message']['msg'] =
Security::cipher($this->data-'Message']['msg'],
Configure::read('Security.cipherSeed'));

You might also want to use $this->log() in a few places to try to
track down where it's going missing. Especially *before* you call
cipher(). Are you certain that the data is even there to begin with?
Check your form fields and the submitted data array.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to