Re: Problems with cipher behavior

2008-09-29 Thread Kanten

Thanks, that removed the PHP errors.

I still have some problems with the behaviour though. It correctly
encrypts the data, but even though autoDecrypt is set to true, it
doesn't decrypt the data. In the log the behaviour outputs:

2008-09-29 11:53:40 Error: CipherBehavior::_unpackValue Enclosed salt
missmatch: '—y÷' != 'G¡ œ' 8
2008-09-29 11:53:40 Error: CipherBehavior::_decryptValue Could not
unpack value from '—y÷G¡ œ'
2008-09-29 11:53:40 Error: CipherBehavior::decrypt Could not decrpyt
Patient::cpr: '$E$4kK+EF1+'

/Anders

On Sep 26, 3:21 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hi Kanten,
 You are running this on an version of PHP where you are no longer
 supposed to define pass_by_reference in functions like before. LIke
 the error said you can allow it in php.ini or fix the behaviour. From
 a quick glance I'd say you could safely remove them since decrypt() is
 defined to accept the arguments as references.

 $this-decrypt($model, $result);
 See the two  there.

 /Martin

 On Sep 26, 2:43 pm, Kanten [EMAIL PROTECTED] wrote:

  Hi,

  I'm experimenting with 
  thecipherbehavior:http://bakery.cakephp.org/articles/view/cipher-behavior

  Unfortunately I keep getting the following error and can't seem to
  figure out how to debug the script myself:

  Warning: Call-time pass-by-reference has been deprecated; If you would
  like to pass it by reference, modify the declaration of [runtime
  function name](). If you would like to enable call-time pass-by-
  reference, you can set allow_call_time_pass_reference to true in your
  INI file in C:\wamp\www\cake\app\models\behaviors\cipher.php on line
  90

  The code section corresponding to this is:

   /** Model hook to decrypt model data if auto decipher is turned on in
  the
      * model behavior configuration. Only primary model data are
  decrypted. */
    function afterFind($model, $result, $primary = false) {
      if (!$result || !isset($this-config[$model-name]['cipher']))
        return $result;

      if ($primary  $this-config[$model-name]['autoDecrypt']) {
        // check for single of multiple model
        $keys = array_keys($result);
        if (!is_numeric($keys[0])) {
          $this-decrypt($model, $result);
        } else {
          foreach($keys as $index) {
            $this-decrypt($model, $result[$index]);
          }
        }
      }
      return $result;
    }

  Any ideas?

  /Anders


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Problems with cipher behavior

2008-09-29 Thread Kanten

You were ofcause absolutely right. The problem was my field in the
database, which was too small. Changed it from VAR(11) to VAR(100) and
the problem was solved.

Thank you very much.

/Anders

On Sep 29, 1:21 pm, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 FYI: I haven't used that behaviour at all.  :)

 The errors you pasted look like encoding issues. You might be
 encrypting data into a field that can't handle the input.
 mypassword is a good varchar(255) but my password ciphered might
 require a blob or at least some other charset.

 When I wrote my own mini-cipher I god pure binary data back from
 Cakes Security::cipher() and had to hex-encode the data before I could
 save it to the database. I also had to do the reverse when reading the
 data back. This was kind of a last-minute hack and I did not like to
 alter the database-schema of a live application.

 This is nothing advanced so here is my code as an example:

 function _encrypt($str) {
 $out = bin2hex(Security::cipher( $str, 'some salt' ));
 return $out;}

 function _decrypt($str) {
   $out = Security::cipher(pack('H*',  $str), 'some salt' );
   return $out;

 }

 After encryption it is bin2hexed and before decryption is is returned
 to binary data.

 On Sep 29, 12:58 pm, Kanten [EMAIL PROTECTED] wrote:

  Thanks, that removed the PHP errors.

  I still have some problems with the behaviour though. It correctly
  encrypts the data, but even though autoDecrypt is set to true, it
  doesn't decrypt the data. In the log the behaviour outputs:

  2008-09-29 11:53:40 Error: CipherBehavior::_unpackValue Enclosed salt
  missmatch: '—y÷' != 'G¡ œ' 8
  2008-09-29 11:53:40 Error: CipherBehavior::_decryptValue Could not
  unpack value from '—y÷G¡ œ'
  2008-09-29 11:53:40 Error: CipherBehavior::decrypt Could not decrpyt
  Patient::cpr: '$E$4kK+EF1+'

  /Anders

  On Sep 26, 3:21 pm, [EMAIL PROTECTED]

  [EMAIL PROTECTED] wrote:
   Hi Kanten,
   You are running this on an version of PHP where you are no longer
   supposed to define pass_by_reference in functions like before. LIke
   the error said you can allow it in php.ini or fix the behaviour. From
   a quick glance I'd say you could safely remove them since decrypt() is
   defined to accept the arguments as references.

   $this-decrypt($model, $result);
   See the two  there.

   /Martin

   On Sep 26, 2:43 pm, Kanten [EMAIL PROTECTED] wrote:

Hi,

I'm experimenting with 
thecipherbehavior:http://bakery.cakephp.org/articles/view/cipher-behavior

Unfortunately I keep getting the following error and can't seem to
figure out how to debug the script myself:

Warning: Call-time pass-by-reference has been deprecated; If you would
like to pass it by reference, modify the declaration of [runtime
function name](). If you would like to enable call-time pass-by-
reference, you can set allow_call_time_pass_reference to true in your
INI file in C:\wamp\www\cake\app\models\behaviors\cipher.php on line
90

The code section corresponding to this is:

 /** Model hook to decrypt model data if auto decipher is turned on in
the
    * model behavior configuration. Only primary model data are
decrypted. */
  function afterFind($model, $result, $primary = false) {
    if (!$result || !isset($this-config[$model-name]['cipher']))
      return $result;

    if ($primary  $this-config[$model-name]['autoDecrypt']) {
      // check for single of multiple model
      $keys = array_keys($result);
      if (!is_numeric($keys[0])) {
        $this-decrypt($model, $result);
      } else {
        foreach($keys as $index) {
          $this-decrypt($model, $result[$index]);
        }
      }
    }
    return $result;
  }

Any ideas?

/Anders


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Problems with cipher behavior

2008-09-29 Thread [EMAIL PROTECTED]

FYI: I haven't used that behaviour at all.  :)

The errors you pasted look like encoding issues. You might be
encrypting data into a field that can't handle the input.
mypassword is a good varchar(255) but my password ciphered might
require a blob or at least some other charset.

When I wrote my own mini-cipher I god pure binary data back from
Cakes Security::cipher() and had to hex-encode the data before I could
save it to the database. I also had to do the reverse when reading the
data back. This was kind of a last-minute hack and I did not like to
alter the database-schema of a live application.

This is nothing advanced so here is my code as an example:

function _encrypt($str) {
$out = bin2hex(Security::cipher( $str, 'some salt' ));
return $out;
}
function _decrypt($str) {
  $out = Security::cipher(pack('H*',  $str), 'some salt' );
  return $out;
}

After encryption it is bin2hexed and before decryption is is returned
to binary data.


On Sep 29, 12:58 pm, Kanten [EMAIL PROTECTED] wrote:
 Thanks, that removed the PHP errors.

 I still have some problems with the behaviour though. It correctly
 encrypts the data, but even though autoDecrypt is set to true, it
 doesn't decrypt the data. In the log the behaviour outputs:

 2008-09-29 11:53:40 Error: CipherBehavior::_unpackValue Enclosed salt
 missmatch: '—y÷' != 'G¡ œ' 8
 2008-09-29 11:53:40 Error: CipherBehavior::_decryptValue Could not
 unpack value from '—y÷G¡ œ'
 2008-09-29 11:53:40 Error: CipherBehavior::decrypt Could not decrpyt
 Patient::cpr: '$E$4kK+EF1+'

 /Anders

 On Sep 26, 3:21 pm, [EMAIL PROTECTED]

 [EMAIL PROTECTED] wrote:
  Hi Kanten,
  You are running this on an version of PHP where you are no longer
  supposed to define pass_by_reference in functions like before. LIke
  the error said you can allow it in php.ini or fix the behaviour. From
  a quick glance I'd say you could safely remove them since decrypt() is
  defined to accept the arguments as references.

  $this-decrypt($model, $result);
  See the two  there.

  /Martin

  On Sep 26, 2:43 pm, Kanten [EMAIL PROTECTED] wrote:

   Hi,

   I'm experimenting with 
   thecipherbehavior:http://bakery.cakephp.org/articles/view/cipher-behavior

   Unfortunately I keep getting the following error and can't seem to
   figure out how to debug the script myself:

   Warning: Call-time pass-by-reference has been deprecated; If you would
   like to pass it by reference, modify the declaration of [runtime
   function name](). If you would like to enable call-time pass-by-
   reference, you can set allow_call_time_pass_reference to true in your
   INI file in C:\wamp\www\cake\app\models\behaviors\cipher.php on line
   90

   The code section corresponding to this is:

    /** Model hook to decrypt model data if auto decipher is turned on in
   the
       * model behavior configuration. Only primary model data are
   decrypted. */
     function afterFind($model, $result, $primary = false) {
       if (!$result || !isset($this-config[$model-name]['cipher']))
         return $result;

       if ($primary  $this-config[$model-name]['autoDecrypt']) {
         // check for single of multiple model
         $keys = array_keys($result);
         if (!is_numeric($keys[0])) {
           $this-decrypt($model, $result);
         } else {
           foreach($keys as $index) {
             $this-decrypt($model, $result[$index]);
           }
         }
       }
       return $result;
     }

   Any ideas?

   /Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Problems with cipher behavior

2008-09-26 Thread [EMAIL PROTECTED]

Hi Kanten,
You are running this on an version of PHP where you are no longer
supposed to define pass_by_reference in functions like before. LIke
the error said you can allow it in php.ini or fix the behaviour. From
a quick glance I'd say you could safely remove them since decrypt() is
defined to accept the arguments as references.

$this-decrypt($model, $result);
See the two  there.

/Martin

On Sep 26, 2:43 pm, Kanten [EMAIL PROTECTED] wrote:
 Hi,

 I'm experimenting with the cipher 
 behavior:http://bakery.cakephp.org/articles/view/cipher-behavior

 Unfortunately I keep getting the following error and can't seem to
 figure out how to debug the script myself:

 Warning: Call-time pass-by-reference has been deprecated; If you would
 like to pass it by reference, modify the declaration of [runtime
 function name](). If you would like to enable call-time pass-by-
 reference, you can set allow_call_time_pass_reference to true in your
 INI file in C:\wamp\www\cake\app\models\behaviors\cipher.php on line
 90

 The code section corresponding to this is:

  /** Model hook to decrypt model data if auto decipher is turned on in
 the
     * model behavior configuration. Only primary model data are
 decrypted. */
   function afterFind($model, $result, $primary = false) {
     if (!$result || !isset($this-config[$model-name]['cipher']))
       return $result;

     if ($primary  $this-config[$model-name]['autoDecrypt']) {
       // check for single of multiple model
       $keys = array_keys($result);
       if (!is_numeric($keys[0])) {
         $this-decrypt($model, $result);
       } else {
         foreach($keys as $index) {
           $this-decrypt($model, $result[$index]);
         }
       }
     }
     return $result;
   }

 Any ideas?

 /Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Problems with cipher behavior

2008-09-26 Thread Kanten

Hi,

I'm experimenting with the cipher behavior:
http://bakery.cakephp.org/articles/view/cipher-behavior

Unfortunately I keep getting the following error and can't seem to
figure out how to debug the script myself:

Warning: Call-time pass-by-reference has been deprecated; If you would
like to pass it by reference, modify the declaration of [runtime
function name](). If you would like to enable call-time pass-by-
reference, you can set allow_call_time_pass_reference to true in your
INI file in C:\wamp\www\cake\app\models\behaviors\cipher.php on line
90

The code section corresponding to this is:

 /** Model hook to decrypt model data if auto decipher is turned on in
the
* model behavior configuration. Only primary model data are
decrypted. */
  function afterFind($model, $result, $primary = false) {
if (!$result || !isset($this-config[$model-name]['cipher']))
  return $result;

if ($primary  $this-config[$model-name]['autoDecrypt']) {
  // check for single of multiple model
  $keys = array_keys($result);
  if (!is_numeric($keys[0])) {
$this-decrypt($model, $result);
  } else {
foreach($keys as $index) {
  $this-decrypt($model, $result[$index]);
}
  }
}
return $result;
  }

Any ideas?

/Anders
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---