{"id":36969399,"url":"https://github.com/aashakib/cakephp-encrypt-decrypt","last_synced_at":"2026-01-13T21:08:10.607Z","repository":{"id":57048795,"uuid":"384761548","full_name":"aashakib/cakephp-encrypt-decrypt","owner":"aashakib","description":"A CakePHP library to encrypt and decrypt data.","archived":false,"fork":false,"pushed_at":"2025-03-18T03:48:57.000Z","size":13,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T15:20:26.083Z","etag":null,"topics":["cakephp","cakephp-plugin","cakephp3","cakephp4","decrypt","decryption","encrypt","encryption","encryption-decryption"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aashakib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-10T18:07:44.000Z","updated_at":"2025-05-23T19:16:20.000Z","dependencies_parsed_at":"2022-08-23T17:50:32.590Z","dependency_job_id":null,"html_url":"https://github.com/aashakib/cakephp-encrypt-decrypt","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/aashakib/cakephp-encrypt-decrypt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashakib%2Fcakephp-encrypt-decrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashakib%2Fcakephp-encrypt-decrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashakib%2Fcakephp-encrypt-decrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashakib%2Fcakephp-encrypt-decrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aashakib","download_url":"https://codeload.github.com/aashakib/cakephp-encrypt-decrypt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aashakib%2Fcakephp-encrypt-decrypt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28400744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cakephp","cakephp-plugin","cakephp3","cakephp4","decrypt","decryption","encrypt","encryption","encryption-decryption"],"created_at":"2026-01-13T21:08:09.981Z","updated_at":"2026-01-13T21:08:10.602Z","avatar_url":"https://github.com/aashakib.png","language":"PHP","readme":"# CakePHP Encrypt Decrypt\nA CakePHP library to encrypt and decrypt data. \n\n### Features\n\n- Encrypt data when saving and decrypt data when fetching data from database.\n- Encrypt \u0026 decrypt historical data.\n\n### Install\n\nVia Composer\n\nFor CakePHP 5 \u0026 CakePHP 4:\n\n`composer require shakib/cakephp-encrypt-decrypt`\n\nFor CakePHP 3.4 and above versions for CakePHP 3.x:\n\n`composer require shakib/cakephp-encrypt-decrypt:~1.1`\n\nFor CakePHP \u003c=3.3:\n\n`composer require shakib/cakephp-encrypt-decrypt:1.0`\n\n### Setup\n\nAdd the type in `bootstrap.php`\n``` php\nTypeFactory::map('encrypted', 'EncryptDecrypt\\Database\\Type\\EncryptType');\n```\nAdd config value in `config\\app.php`\n``` php\n'Security' =\u003e [\n    'encryption_key' =\u003e env('ENCRYPTION_KEY', 'YOUR-KEY'),\n]\n```\n\n### Uses\nTable structure: Use `BLOB \\ VARBINARY` type for those columns you are want to be encrypted. Such as:\n``` sql\nCREATE TABLE `accounts`(\n    `id` INT NOT NULL AUTO_INCREMENT,\n    `full_name` VARCHAR(100) NOT NULL,    \n    `account_number` VARBINARY(255) NOT NULL,    \n    `email` VARBINARY(255) NOT NULL,    \n    `created` DATETIME NOT NULL,\n    `modified` DATETIME NULL,\n    PRIMARY KEY(`id`)\n) ENGINE = InnoDB;\n```\n\nMap all columns in your Table class.\n``` php\nuse Cake\\ORM\\Table;\nuse Cake\\Database\\Schema\\TableSchemaInterface;\nuse EncryptDecrypt\\Traits\\EncryptDecrypt;\n\nclass AccountsTable extends Table\n{\n\n   use EncryptDecrypt;\n    \n   /**\n    * @param TableSchemaInterface $schema\n    * @return TableSchemaInterface\n    */\n    protected function _initializeSchema(TableSchemaInterface $schema): TableSchemaInterface\n    {\n      $schema-\u003esetColumnType('account_number', 'encrypted');\n      $schema-\u003esetColumnType('email', 'encrypted');\n      \n      return $schema;\n    }\n}\n```\n\nTo encrypt or decrypt historical data, add this method in your table class and run\n``` php\npublic function encryptDecryptAllData()\n{\n  // columns that are in plain text\n  $sourceColumns = ['column1', 'column2']; \t\n  // columns that need to be encrypted / decrypted\n  $destinationColumns = ['column3', 'column4'];\n\n  return $this-\u003eencryptAll($this, $sourceColumns, $destinationColumns);\n}\n```\n\nTo search any data, you can use search text in where clause\n``` php\n$query-\u003ewhere(['email' =\u003e 'test@domain.com', 'account_number' =\u003e 'xxxxxxxxx']);\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faashakib%2Fcakephp-encrypt-decrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faashakib%2Fcakephp-encrypt-decrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faashakib%2Fcakephp-encrypt-decrypt/lists"}