{"id":18546768,"url":"https://github.com/nabeghe/simple-cipher-php","last_synced_at":"2026-01-30T16:06:51.560Z","repository":{"id":258612545,"uuid":"875302123","full_name":"nabeghe/simple-cipher-php","owner":"nabeghe","description":"A simple cipher using OpenSSL with a few additional tweaks.","archived":false,"fork":false,"pushed_at":"2024-10-19T21:00:33.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T11:12:27.616Z","etag":null,"topics":["cipher","cipher-algorithms","openssl","openssl-tools","php","php-library","phplibrary","security"],"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/nabeghe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-19T16:10:31.000Z","updated_at":"2024-10-21T12:57:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"4de1c33b-90a4-45aa-b8e8-a753f15ba2da","html_url":"https://github.com/nabeghe/simple-cipher-php","commit_stats":null,"previous_names":["nabeghe/simple-cipher-php"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fsimple-cipher-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fsimple-cipher-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fsimple-cipher-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nabeghe%2Fsimple-cipher-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nabeghe","download_url":"https://codeload.github.com/nabeghe/simple-cipher-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107245,"owners_count":21048884,"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":["cipher","cipher-algorithms","openssl","openssl-tools","php","php-library","phplibrary","security"],"created_at":"2024-11-06T20:26:54.329Z","updated_at":"2026-01-30T16:06:51.554Z","avatar_url":"https://github.com/nabeghe.png","language":"PHP","readme":"# Simple Cipher for PHP ≥ 7.4\n\n\u003e A simple cipher using OpenSSL with a few additional tweaks.\n\nImplementing a cipher to encrypt and decrypt your data can be a bit tricky, but with OpenSSL, it's a breeze.\nHowever, this library combines several techniques to give you a simple yet effective way to handle encryption and\ndecryption.\nYou don’t even need to set a secret or password for your cipher system!\nIf you don’t specify one,\na default value is used that’s unique and remains constant throughout the program, except in special cases.\nHowever, it's not recommended\n\nThe best part? You'll be working with a SimpleCipher class here,\nwhere its methods are accessible both statically and through object instances.\nData is returned in the same type it was encrypted with, ensuring consistency.\nbut objects converted into arrays, and you also have the option to set a default value in case there’s an issue with\ndecryption.\n\n## 🫡 Usage\n\n### 🚀 Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require nabeghe/simple-cipher\n```\n\n### Configuration\n\nThe configuration can be an array, string, number, or null.\nA string or number means setting the secret (password), null means using default values, and an array allows for setting each option separately.\n\n#### Array Syntax:\n\n| Optiona name  | Description                                                                                                                                                                                                                                                                            |\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| algo          | The cipher method.\u003cbr\u003eDefault: aes-256-gcm                                                                                                                                                                                                                                             |\n| secret        | The cipher secret (password).\u003cbr\u003eDefault: A random value is generated at the start \u0026 stored in a file within the library's directory. However, the priority is first given to a constant named `SIMPLE_CIPHER_SECRET`, , and then to an environment key with the same name in `$_ENV`. |\n| default       | A default value is used in case there’s an issue in the decryption process, which is null if not set.                                                                                                                                                                                  |\n\n### Static Mode\n\n#### Syntax:\n\n```php\nSimpleCipher::encrypt(mixed $data, array|string|int|null $config): string;\n\nSimpleCipher::decrypt(string $data, array|string|int|null $config): mixed;\n```\n\n#### Example:\n\n```php\nuse Nabeghe\\SimpleCipher\\SimpleCipher;\n\n$data = 'nabeghe/simple-cipher';\n\n$encrypted = SimpleCipher::encrypt($data, 'YOUR_SECRET');\necho \"Encrypted Data:\\n\";\necho \"$encrypted\\n\\n\";\n\n$decrypted = SimpleCipher::decrypt($encrypted, 'YOUR_SECRET');\necho \"Decrypted Data:\\n\";\nvar_dump($decrypted);\n```\n\n### Instance Mode\n\n#### Syntax:\n\n```php\n__construct(array|string|int|null $config = null)\n\n$cipher-\u003eencrypt(mixed $data): string;\n\n$cipher-\u003edecrypt(string $data, mixed $default = null): mixed;\n```\n\n#### Example:\n\n```php\nuse Nabeghe\\SimpleCipher\\SimpleCipher;\n\n$data = 'nabeghe/simple-cipher';\n\n$cipher = new SimpleCipher('YOUR_SECRET');\n\n$encrypted = $cipher-\u003eencrypt($data);\necho \"Encrypted Data:\\n\";\necho \"$encrypted\\n\\n\";\n\n$decrypted = $cipher-\u003edecrypt($encrypted);\necho \"Decrypted Data:\\n\";\nvar_dump($decrypted);\n```\n\n## 📖 License\n\nLicensed under the MIT license, see [LICENSE.md](LICENSE.md) for details.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeghe%2Fsimple-cipher-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnabeghe%2Fsimple-cipher-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnabeghe%2Fsimple-cipher-php/lists"}