{"id":21771146,"url":"https://github.com/initphp/encryption","last_synced_at":"2025-04-13T16:41:28.757Z","repository":{"id":56991534,"uuid":"470028612","full_name":"InitPHP/Encryption","owner":"InitPHP","description":"It is an easy-to-use library for encrypting data and decryption encrypted data.","archived":false,"fork":false,"pushed_at":"2022-04-23T02:18:53.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T07:35:53.121Z","etag":null,"topics":["encryption","encryption-decryption","openssl","openssl-library","php","php-encryption","php-openssl","php-sodium","php7","sodium","sodium-library"],"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/InitPHP.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":"2022-03-15T06:10:35.000Z","updated_at":"2023-12-20T19:18:14.000Z","dependencies_parsed_at":"2022-08-21T10:10:40.815Z","dependency_job_id":null,"html_url":"https://github.com/InitPHP/Encryption","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEncryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEncryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEncryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InitPHP%2FEncryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InitPHP","download_url":"https://codeload.github.com/InitPHP/Encryption/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248747106,"owners_count":21155394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["encryption","encryption-decryption","openssl","openssl-library","php","php-encryption","php-openssl","php-sodium","php7","sodium","sodium-library"],"created_at":"2024-11-26T14:15:13.389Z","updated_at":"2025-04-13T16:41:28.737Z","avatar_url":"https://github.com/InitPHP.png","language":"PHP","readme":"# Encryption\nPHP OpenSSL/Sodium Encryption and Decryption\n\n[![Latest Stable Version](http://poser.pugx.org/initphp/encryption/v)](https://packagist.org/packages/initphp/encryption) [![Total Downloads](http://poser.pugx.org/initphp/encryption/downloads)](https://packagist.org/packages/initphp/encryption) [![Latest Unstable Version](http://poser.pugx.org/initphp/encryption/v/unstable)](https://packagist.org/packages/initphp/encryption) [![License](http://poser.pugx.org/initphp/encryption/license)](https://packagist.org/packages/initphp/encryption) [![PHP Version Require](http://poser.pugx.org/initphp/encryption/require/php)](https://packagist.org/packages/initphp/encryption)\n\n## Requirements\n\n- PHP 7.4 or higher\n- MB_String extension\n- Depending on usage: \n  - OpenSSL extesion\n  - Sodium extension\n\n\n## Installation\n\n```\ncomposer require initphp/encryption\n```\n\n## Configuration\n\n```php \n$options = [\n    'algo'      =\u003e 'SHA256',\n    'cipher'    =\u003e 'AES-256-CTR',\n    'key'       =\u003e null,\n    'blocksize' =\u003e 16,\n];\n```\n\n- `algo` : Used by OpenSSL handler only. The algorithm to use to sign the data.\n- `cipher` : Used by OpenSSL handler only. The encryption algorithm that will be used to encrypt the data.\n- `key` : The top secret key string to use for encryption.\n- `blocksize` : It is used for sodium handler only. It is used in the `sodium_pad()` and `sodium_unpad()` functions.\n\n\n## Usage\n\n```php \nrequire_once \"vendor/autoload.php\";\nuse \\InitPHP\\Encryption\\Encrypt;\n\n// OpenSSL Handler\n/** @var $openssl \\InitPHP\\Encryption\\HandlerInterface */\n$openssl = Encrypt::use(\\InitPHP\\Encryption\\OpenSSL::class, [\n    'algo'      =\u003e 'SHA256',\n    'cipher'    =\u003e 'AES-256-CTR',\n    'key'       =\u003e 'TOP_Secret_Key',\n]);\n\n// Sodium Handler\n/** @var $sodium \\InitPHP\\Encryption\\HandlerInterface */\n$sodium = Encrypt::use(\\InitPHP\\Encryption\\Sodium::class, [\n    'key'       =\u003e 'TOP_Secret_Key',\n    'blocksize' =\u003e 16,\n]);\n```\n\n### Methods\n\n#### `encrypt()`\n\n```php \npublic function encrypt(mixed $data, array $options = []): string;\n```\n\n#### `decrypt()`\n\n```php \npublic function decrypt(string $data, array $options = []): mixed;\n```\n\n## Writing Your Own Handler\n\n```php \nnamespace App;\n\nuse \\InitPHP\\Encryption\\{HandlerInterface, BaseHandler};\n\nclass MyHandler extends BaseHandler implements HandlerInterface\n{\n    public function encrypt($data, array $options = []): string\n    {\n        $options = $this-\u003eoptions($options);\n        // ... process\n    }\n\n    public function decrypt($data, array $options = [])\n    {\n        $options = $this-\u003eoptions($options);\n        // ... process\n    }\n}\n```\n\n```php \nuse \\InitPHP\\Encryption\\Encrypt;\n\n$myhandler = Encrypt::use(\\App\\MyHandler::class);\n```\n\n## Getting Help\n\nIf you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.\n\n## Getting Involved\n\n\u003e All contributions to this project will be published under the MIT License. By submitting a pull request or filing a bug, issue, or feature request, you are agreeing to comply with this waiver of copyright interest.\n\nThere are two primary ways to help:\n\n- Using the issue tracker, and\n- Changing the code-base.\n    \n### Using the issue tracker\n\nUse the issue tracker to suggest feature requests, report bugs, and ask questions. This is also a great way to connect with the developers of the project as well as others who are interested in this solution.\n\nUse the issue tracker to find ways to contribute. Find a bug or a feature, mention in the issue that you will take on that effort, then follow the Changing the code-base guidance below.\n\n### Changing the code-base\n\nGenerally speaking, you should fork this repository, make changes in your own fork, and then submit a pull request. All new code should have associated unit tests that validate implemented features and the presence or lack of defects. Additionally, the code should follow any stylistic and architectural guidelines prescribed by the project. In the absence of such guidelines, mimic the styles and patterns in the existing code-base.\n\n## Credits\n\n- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr)\n\n## License\n\nCopyright \u0026copy; 2022 [MIT License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fencryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finitphp%2Fencryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finitphp%2Fencryption/lists"}