PHPackages                             shakib/cakephp-encrypt-decrypt - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. shakib/cakephp-encrypt-decrypt

ActivePhp[Database &amp; ORM](/categories/database)

shakib/cakephp-encrypt-decrypt
==============================

A CakePHP plugin to encrypt data and save in database and also to decrypt data when fethcing from database. You can also encrypt or decrypt all historical data.

v2.4(1mo ago)22121MITPHP

Since Jul 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/aashakib/cakephp-encrypt-decrypt)[ Packagist](https://packagist.org/packages/shakib/cakephp-encrypt-decrypt)[ RSS](/packages/shakib-cakephp-encrypt-decrypt/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

CakePHP Encrypt Decrypt
=======================

[](#cakephp-encrypt-decrypt)

A CakePHP library to encrypt and decrypt data.

### Features

[](#features)

- Encrypt data when saving and decrypt data when fetching data from database.
- Encrypt &amp; decrypt historical data.

### Install

[](#install)

Via Composer

For CakePHP 5:

`composer require shakib/cakephp-encrypt-decrypt`

For CakePHP 4:

`composer require shakib/cakephp-encrypt-decrypt:~2.2`

For CakePHP 3.4 and above versions for CakePHP 3.x:

`composer require shakib/cakephp-encrypt-decrypt:~1.1`

For CakePHP &lt;=3.3:

`composer require shakib/cakephp-encrypt-decrypt:1.0`

### Setup

[](#setup)

Add the type in `bootstrap.php`

```
TypeFactory::map('encrypted', 'EncryptDecrypt\Database\Type\EncryptType');
```

Add config value in `config\app.php`

```
'Security' => [
    'encryption_key' => env('ENCRYPTION_KEY', 'YOUR-KEY'),
]
```

### Uses

[](#uses)

Table structure: Use `BLOB \ VARBINARY` type for those columns you are want to be encrypted. Such as:

```
CREATE TABLE `accounts`(
    `id` INT NOT NULL AUTO_INCREMENT,
    `full_name` VARCHAR(100) NOT NULL,
    `account_number` VARBINARY(255) NOT NULL,
    `email` VARBINARY(255) NOT NULL,
    `created` DATETIME NOT NULL,
    `modified` DATETIME NULL,
    PRIMARY KEY(`id`)
) ENGINE = InnoDB;
```

Map all columns in your Table class.

```
use Cake\ORM\Table;
use Cake\Database\Schema\TableSchemaInterface;
use EncryptDecrypt\Traits\EncryptDecrypt;

class AccountsTable extends Table
{

   use EncryptDecrypt;

    public function initialize(array $config): void
    {

        parent::initialize($config);

        //... rest of initialization

      $this->getSchema()->setColumnType('account_number', 'encrypted');
      $this->getSchema()->setColumnType('email', 'encrypted');

    }
}
```

To encrypt or decrypt historical data, add this method in your table class and run

```
public function encryptDecryptAllData()
{
  // columns that are in plain text
  $sourceColumns = ['column1', 'column2'];
  // columns that need to be encrypted / decrypted
  $destinationColumns = ['column3', 'column4'];

  return $this->encryptAll($this, $sourceColumns, $destinationColumns);
}
```

To search any data, you can use search text in where clause

```
$query->where(['email' => 'test@domain.com', 'account_number' => 'xxxxxxxxx']);
}
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~286 days

Recently: every ~428 days

Total

7

Last Release

58d ago

Major Versions

v1.0 → v2.02021-07-10

v1.1 → v2.22021-07-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/f349f7fc95294f382a364dc9d6686ff9f1727762094a8c3a6590b16f25c54364?d=identicon)[shakib](/maintainers/shakib)

---

Top Contributors

[![aashakib](https://avatars.githubusercontent.com/u/4949734?v=4)](https://github.com/aashakib "aashakib (10 commits)")[![impronta48](https://avatars.githubusercontent.com/u/5368022?v=4)](https://github.com/impronta48 "impronta48 (2 commits)")

---

Tags

cakephpcakephp-plugincakephp3cakephp4decryptdecryptionencryptencryptionencryption-decryptiontypeencryptiondatabasecakephpencryptdecryptcakephp3encryptedcakephp4cakephp5

### Embed Badge

![Health badge](/badges/shakib-cakephp-encrypt-decrypt/health.svg)

```
[![Health](https://phpackages.com/badges/shakib-cakephp-encrypt-decrypt/health.svg)](https://phpackages.com/packages/shakib-cakephp-encrypt-decrypt)
```

###  Alternatives

[betterapp/laravel-db-encrypter

Provides database model attribute encryption/decryption

365614.7k8](/packages/betterapp-laravel-db-encrypter)[dereuromark/cakephp-databaselog

A CakePHP plugin for storing and viewing application logs in the database

44165.0k2](/packages/dereuromark-cakephp-databaselog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
