07.28
php
saved
rpeterson
Note
reffers to http://groups.google.com/group/cake-php/browse_thread/thread/f38b7ddd1f770b3e
reffers to http://groups.google.com/group/cake-php/browse_thread/thread/f38b7ddd1f770b3e
- <?php
- class AesBehavior extends ModelBehavior
- {
- var $aesKey;
- {
- $this->aesKey = AES_SECURE_KEY;
- }
- function beforeFind(&$model, $queryData)
- {
- foreach($model->cryptedFields AS $key => $field)
- {
- {
- $queryData['fields'] = str_replace($field,"AES_DECRYPT({$field}, {$this->aesKey})", $queryData['fields']);
- }
- }
- return $queryData;
- }
- function beforeSave(&$model)
- {
- foreach($model->data[$model->name] AS $key => $value)
- {
- {
- $model->data[$model->name][$key] = "AES_ENCRYPT({$value}, {$this->aesKey})";
- }
- }
- }
- }
- ?>
Parsed in 0.036 seconds, using GeSHi 1.0.7.14