{"id":20963504,"url":"https://github.com/ialopezg/encryption","last_synced_at":"2025-06-12T17:03:50.370Z","repository":{"id":56988037,"uuid":"297952628","full_name":"ialopezg/encryption","owner":"ialopezg","description":"Encryption Library for PHP","archived":false,"fork":false,"pushed_at":"2020-09-24T01:11:12.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T01:31:55.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ialopezg.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":"2020-09-23T11:48:14.000Z","updated_at":"2021-07-24T18:24:59.000Z","dependencies_parsed_at":"2022-08-21T12:50:26.358Z","dependency_job_id":null,"html_url":"https://github.com/ialopezg/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/ialopezg%2Fencryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ialopezg%2Fencryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ialopezg%2Fencryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ialopezg%2Fencryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ialopezg","download_url":"https://codeload.github.com/ialopezg/encryption/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243360159,"owners_count":20278338,"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":[],"created_at":"2024-11-19T02:46:06.105Z","updated_at":"2025-03-13T07:24:55.873Z","avatar_url":"https://github.com/ialopezg.png","language":"PHP","readme":"\u003ch1 style=\"text-align: center;\"\u003eCryptography Library\u003c/h1\u003e\n\n\u003cp style=\"text-align: center;\"\u003e\n    \u003ca href=\"https://github.com/ialopezg/encryption/releases\"\u003e\u003cimg alt=\"Version\" src=\"https://img.shields.io/github/release/ialopezg/encryption.svg?label=version\u0026color=green\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ialopezg/encryption/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg?color=green\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ialopezg/encryption\"\u003e\u003cimg src=\"https://img.shields.io/github/downloads/ialopezg/encryption/total.svg?color=green\" alt=\"Total downloads\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nCryptography Library for PHP\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Usage instructions](#usage-instructions)\n- [License](#license)\n\n## Installation\n\n1. Package manager\n    - Composer\n        ```shell script\n        composer require ialopezg/encryption\n        ```\n\n2. Manually\n    - **Github**\n        ```shell script\n        git clone https://github.com/ialopezg/encryption\n        ```\n\n## Features\n\n| Library | Description |\n|---|---|\n| \u003ca href=\"#iteratorobject\"\u003e`Password`\u003c/a\u003e | Library for password manipulation. |\n\n\n## Requirements\n\n* **PHP** *v5.6+*\n* **ext-mbstring** PHP extension\n* **ext-openssl** PHP extension\n* **ialopezg/core** *v0.0.1+*\n* **ialopezg/logger** *v0.0.4+*\n\n## Usage instructions\n\n### IteratorObject\n\n### Methods\n\n| Method | Description |\n|---|---|\n| \u003ca href=\"#password_createKey\"\u003e`createKey()`\u003c/a\u003e | Creates a random key with the lengh provided. Optional the result could be returned with capital letters. |\n| \u003ca href=\"#password_getOption\"\u003e`getOption()`\u003c/a\u003e | Gets an option value. If value does not exists will return the default value. |\n| \u003ca href=\"#password_hash\"\u003e`hash()`\u003c/a\u003e | Encrypts a simple text password into a ciphered password. |\n| \u003ca href=\"#password_setOption\"\u003e`setOption()`\u003c/a\u003e | Sets an option value. |\n| \u003ca href=\"#password_verify\"\u003e`verify()`\u003c/a\u003e | Encrypts a plain text into cipher text. |\n\n#### Method Details\n\n##### \u003ca name=\"password_createKey\"\u003e\u003c/a\u003e Method: `createdKey()`\n\n```php\n/**\n * Creates a random key with the length specified. Optional the result could be returned with capital letters.\n *\n * @param int $length       Output length.\n * @param bool $capitalize  Whether if the result key will be returned with capital letters.\n *\n * @throws Exception If it was not possible to gather sufficient entropy.\n * @return string A random key.\n */\npublic static function createKey($length, $capitalize = false): string\n```\n\n**Examples**\n\n```php\n$key = \\ialopezg\\Libraries\\Encryption\\Password::createKey(8, true);\n\n// Display the encryption key string\necho \"Encryption key: \u003cstrong\u003e{$key}\u003c/strong\u003e\u003cbr\u003e\";\n```\n\n##### \u003ca name=\"password_getOption\"\u003e\u003c/a\u003e Method: `getOption()`\n\n```php\n/**\n * Gets an option value. If value does not exists will return the default value.\n *\n * @param string $key Option key name.\n * @param null $default Option default value.\n *\n * @return mixed\n */\npublic function getOption($key, $default = null): string\n```\n\n**Examples**\n\n```php\n$encrypter-\u003esetOption('key', Password::createKey(8, true);\n\n// Display the encryption key string\necho \"Encryption key: \u003cstrong\u003e{$encrypter-\u003egetOption('key')}\u003c/strong\u003e\u003cbr\u003e\";\n```\n\n##### \u003ca name=\"password_hash\"\u003e\u003c/a\u003e Method: `hash()`\n\n```php\n/**\n * Encrypts a simple text password into a ciphered password.\n * \n * @param string $password Plain text password.\n * \n * @return string Ciphered password.\n * @throws Exception If data provided is not a string.\n */\npublic function hash($password): string\n```\n\n**Examples**\n\n```php\n$encrypter = new \\ialopezg\\Libraries\\Encryption\\Password([\n    'cipher' =\u003e 'AES-128-CTR',\n    'digest' =\u003e 'SHA512',\n    'options' =\u003e OPENSSL_CIPHER_RC2_40,\n    'key' =\u003e 'YOUR_SECRET_KEY'\n]);\n$encrypted_password = $encrypter-\u003eencrypt($password);\n\n// Display the encrypted string\necho \"Encrypted password: \u003cstrong\u003e{$encrypted_password}\u003c/strong\u003e\u003cbr\u003e\";\n```\n\n##### \u003ca name=\"password_setOption\"\u003e\u003c/a\u003e Method: `setOption()`\n\n```php\n/**\n * Sets an option value.\n *\n * @param string $key Option key name.\n * @param mixed $value Option value.\n *\n * @return void\n */\npublic function setOption($key, $value): string\n```\n\n**Examples**\n\n```php\n$encrypter = new \\ialopezg\\Libraries\\Encryption\\Password();\n$encrypter-\u003esetOption('key', $key);\n```\n\n##### \u003ca name=\"password_verify\"\u003e\u003c/a\u003e Method: `verify()`\n\n```php\n/**\n * Verifies if a hashed password is equal to the plain tex provided.\n *\n * @param string $password Plain text password.\n * @param string $hash Ciphered text\n *\n * @return bool true If password equals to hash, false otherwise.\n * @throws Exception If data provided is not a string.\n */\npublic function verify($password, $hash): bool\n```\n\n**Examples**\n\n```php\n$encrypter = new \\ialopezg\\Libraries\\Encryption\\Password();\n\n$password = 'YOUR_PASSWORD';\n$encrypted_password = 'YOUR_ENCRYPTED_PASSWORD';\n\n// Display the encrypted string\necho 'Password are equals: \u003cstrong\u003e' . ($encrypter-\u003everify($password, $encrypted_password) ? 'true' : 'false') . '\u003c/strong\u003e';\n```\n\nFor more examples or options, see [examples](examples) directory. For live examples, run:\n\n```shell script\n### linux bash\n./server.sh\n``` \nor\n```shell script\n### windows prompt\nserver.bat\n``` \n\n## License\n\nThis project is under the MIT license. For more information see [LICENSE](https://github.com/ialopezg/core/blob/master/LICENSE).\n\nCopyright (c) [Isidro A. López G.](https://ialopezg.com/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fialopezg%2Fencryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fialopezg%2Fencryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fialopezg%2Fencryption/lists"}