cakephp 2.8 keep encrypted data in database not working
<p>I have to keep 2 fields(<code>question</code>,<code>options</code>) of questions table in encrypted form</p>

<p>core.php</p>

<pre><code>Configure::write('Security.ekey', '1234567890~`!@#$%^&amp;*()_+-={}[]&lt;&gt;,./?qwertrpoiuytlkskhsffgzxmnxcbvLAKSJHFJPOQWUTERLKDJAD');
</code></pre>

<p>in <code>Question</code> modal i have</p>

<pre><code>public $encryptedFields = array('question', 'options');
public function beforeSave($options = array()) {    
        foreach($this-&gt;encryptedFields as $fieldName){
            if(!empty($this-&gt;data[$this-&gt;alias][$fieldName])){
                $this-&gt;data[$this-&gt;alias][$fieldName] = Security::rijndael(
                        $this-&gt;data[$this-&gt;alias][$fieldName],
                        Configure::read('Security.ekey'), 'encrypt');
            }
        }
        return true;
    }

 public function afterFind($results, $primary = false) {
     //debug($results); this return nothing while data is being displayed having question and option fields null
    foreach($this-&gt;encryptedFields as $fieldName){
        if(!empty($results[$this-&gt;alias][$fieldName])){
            $results[$this-&gt;alias][$fieldName] = Security::rijndael(
                    $results[$this-&gt;alias][$fieldName], 
                    Configure::read('Security.ekey'), 'decrypt');
        }
    }
    return $results;
}
</code></pre>

<p>I have searched different blogs and stackoverflow questions<br>
also tried changing datatype of fields to (text,blob,longblob)
length of these fields may be long (equalent to text datatype) please also suggest which datatype will be best to keep its encrypted string.   </p>