Skip to content

How to set up encryption on model

Lukas Polak edited this page May 1, 2014 · 1 revision

There's several things you need to do before you can turn on encryption on your documents on database level.

First, you need to add this repository to your composer:

"phpseclib/phpseclib" : "dev-php5"

Then, you need to create an encryption key. Each cipher has a different requirements on length of the key. The requirements are listed here. Create a key.ini file in config directory and write the encryption key there. A good idea is to run these commands in shell on it (so the file belongs to apache process and only apache can read it):

chmod 400 key.ini
chown apache key.ini

Now, you need to tell your model which fields should be encrypted and add encryption trait there:

use \Dsc\Traits\Models\Encryptable;

protected $__config = array(
		'encrypted_fields' => array(
				'title'
		)
);

And that's all

Clone this wiki locally