{"id":21467409,"url":"https://github.com/elusivecodes/fyreencryption","last_synced_at":"2025-07-20T00:33:26.948Z","repository":{"id":62508425,"uuid":"377135039","full_name":"elusivecodes/FyreEncryption","owner":"elusivecodes","description":"FyreEncryption is a free, open-source encryption library for PHP.","archived":false,"fork":false,"pushed_at":"2025-07-03T10:18:58.000Z","size":93,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-15T09:04:08.419Z","etag":null,"topics":["encryption","library","openssl","php","sodium"],"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/elusivecodes.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-15T11:13:52.000Z","updated_at":"2025-07-03T10:18:40.000Z","dependencies_parsed_at":"2024-06-29T07:40:20.504Z","dependency_job_id":"03496130-6b9d-4592-a99c-c064c3f42f68","html_url":"https://github.com/elusivecodes/FyreEncryption","commit_stats":null,"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/elusivecodes/FyreEncryption","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEncryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEncryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEncryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEncryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreEncryption/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreEncryption/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266048676,"owners_count":23868743,"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","library","openssl","php","sodium"],"created_at":"2024-11-23T08:17:54.381Z","updated_at":"2025-07-20T00:33:26.916Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreEncryption\r\n\r\n**FyreEncryption** is a free, open-source encryption library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Encrypters](#encrypters)\r\n    - [OpenSSL](#openssl)\r\n    - [Sodium](#sodium)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/encryption\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Encryption\\EncryptionManager;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n```php\r\n$encryptionManager = new EncryptionManager($container, $config);\r\n```\r\n\r\nDefault configuration options will be resolved from the \"*Encryption*\" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *EncryptionManager* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(EncryptionManager::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$encryptionManager = $container-\u003euse(EncryptionManager::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Build**\r\n\r\nBuild an [*Encrypter*](#encrypters).\r\n\r\n- `$options` is an array containing configuration options.\r\n\r\n```php\r\n$encrypter = $encryptionManager-\u003ebuild($options);\r\n```\r\n\r\n[*Encrypter*](#encrypters) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n**Clear**\r\n\r\nClear all instances and configs.\r\n\r\n```php\r\n$encryptionManager-\u003eclear();\r\n```\r\n\r\n**Get Config**\r\n\r\nGet an [*Encrypter*](#encrypters) config.\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key.\r\n\r\n```php\r\n$config = $encryptionManager-\u003egetConfig($key);\r\n```\r\n\r\nAlternatively, if the `$key` argument is omitted an array containing all configurations will be returned.\r\n\r\n```php\r\n$config = $encryptionManager-\u003egetConfig();\r\n```\r\n\r\n**Has Config**\r\n\r\nDetermine whether an [*Encrypter*](#encrypters) config exists.\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.\r\n\r\n```php\r\n$hasConfig = $encryptionManager-\u003ehasConfig($key);\r\n```\r\n\r\n**Is Loaded**\r\n\r\nDetermine whether an [*Encrypter*](#encrypters) instance is loaded.\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.\r\n\r\n```php\r\n$isLoaded = $encryptionManager-\u003eisLoaded($key);\r\n```\r\n\r\n**Set Config**\r\n\r\nSet the [*Encrypter*](#encrypters) config.\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key.\r\n- `$options` is an array containing configuration options.\r\n\r\n```php\r\n$encryptionManager-\u003esetConfig($key, $options);\r\n```\r\n\r\n**Unload**\r\n\r\nUnload an [*Encrypter*](#encrypters).\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.\r\n\r\n```php\r\n$encryptionManager-\u003eunload($key);\r\n```\r\n\r\n**Use**\r\n\r\nLoad a shared [*Encrypter*](#encrypters) instance.\r\n\r\n- `$key` is a string representing the [*Encrypter*](#encrypters) key, and will default to `EncryptionManager::DEFAULT`.\r\n\r\n```php\r\n$encrypter = $encryptionManager-\u003euse($key);\r\n```\r\n\r\n[*Encrypter*](#encrypters) dependencies will be resolved automatically from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n\r\n## Encrypters\r\n\r\nYou can load a specific encrypter by specifying the `className` option of the `$options` variable above.\r\n\r\nCustom encrypters can be created by extending `\\Fyre\\Encryption\\Encrypter`, ensuring all below methods are implemented.\r\n\r\n**Decrypt**\r\n\r\nDecrypt data.\r\n\r\n- `$data` is the encrypted data.\r\n- `$key` is a string representing the encryption key.\r\n\r\n```php\r\n$decrypted = $encrypter-\u003edecrypt($data, $key);\r\n```\r\n\r\n**Encrypt**\r\n\r\nEncrypt data.\r\n\r\n- `$data` is the data to encrypt.\r\n- `$key` is a string representing the encryption key.\r\n\r\n```php\r\n$encrypted = $encrypter-\u003eencrypt($data, $key);\r\n```\r\n\r\n**Generate Key**\r\n\r\nGenerate an encryption key.\r\n\r\n```php\r\n$key = $encrypter-\u003egenerateKey();\r\n```\r\n\r\n\r\n### OpenSSL\r\n\r\nThe OpenSSL encrypter can be loaded using default configuration using the \"*openssl*\" key.\r\n\r\n```php\r\n$encrypter = $encryptionManager-\u003euse('openssl');\r\n```\r\n\r\nYou can also load the OpenSSL encrypter using custom configuration.\r\n\r\n- `$options` is an array containing configuration options.\r\n    - `className` must be set to `\\Fyre\\Encryption\\Handlers\\OpenSSLEncrypter::class`.\r\n    - `cipher` is a string representing the cipher, and will default to \"*AES-256-CTR*\".\r\n    - `digest` is a string representing the digest, and will default to \"*SHA512*\".\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('Encryption.openssl', $options);\r\n```\r\n\r\n\r\n### Sodium\r\n\r\nThe Sodium encrypter is the default handler.\r\n\r\n```php\r\n$encrypter = $encryptionManager-\u003euse();\r\n```\r\n\r\nYou can also load the Sodium encrypter using custom configuration.\r\n\r\n- `$options` is an array containing configuration options.\r\n    - `className` must be set to `\\Fyre\\Encryption\\Handlers\\SodiumEncrypter::class`.\r\n    - `blockSize` is a number representing the block size, and will default to *16*.\r\n    - `digest` is a string representing the digest, and will default to \"*SHA512*\".\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('Encryption.default', $options);\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreencryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreencryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreencryption/lists"}