{"id":20324044,"url":"https://github.com/charlesportwoodii/php-argon2-ext","last_synced_at":"2025-07-13T18:37:11.738Z","repository":{"id":143071010,"uuid":"62176992","full_name":"charlesportwoodii/php-argon2-ext","owner":"charlesportwoodii","description":"PHP7 extension for Argon2","archived":false,"fork":false,"pushed_at":"2018-02-16T19:07:43.000Z","size":38,"stargazers_count":33,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T15:32:44.714Z","etag":null,"topics":["argon","argon2-library","hash","php","php7-extension"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/charlesportwoodii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2016-06-28T21:58:59.000Z","updated_at":"2023-10-08T14:24:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae883e34-3bb7-4511-975b-0837ce7447e5","html_url":"https://github.com/charlesportwoodii/php-argon2-ext","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesportwoodii%2Fphp-argon2-ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesportwoodii%2Fphp-argon2-ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesportwoodii%2Fphp-argon2-ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/charlesportwoodii%2Fphp-argon2-ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/charlesportwoodii","download_url":"https://codeload.github.com/charlesportwoodii/php-argon2-ext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248467384,"owners_count":21108632,"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":["argon","argon2-library","hash","php","php7-extension"],"created_at":"2024-11-14T19:31:49.814Z","updated_at":"2025-04-11T19:33:54.928Z","avatar_url":"https://github.com/charlesportwoodii.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Argon2 Extension\n\n[![TravisCI](https://img.shields.io/travis/charlesportwoodii/php-argon2-ext.svg?style=flat-square \"TravisCI\")](https://travis-ci.org/charlesportwoodii/php-argon2-ext)\n[![License](https://img.shields.io/badge/license-BSD-orange.svg?style=flat-square \"License\")](https://github.com/charlesportwoodii//php-argon2-ext/blob/master/LICENSE.md)\n\n\nThis PHP7 extension provides a simplified interface to the [Argon2](https://github.com/P-H-C/phc-winner-argon2) algorithm, the winner of the [Password Hashing Competition](https://password-hashing.net/). Argon2 is considered the successor to bcrypt/scrypt/pbkdf methods of securely hasing passwords. This project is in no way associated with or endorsed by the PHC team.\n\n\u003e Note this is extension is only compatible with PHP7+. Support for lower versions of PHP will not be considered.\n\n## Building\n\n```bash\n# Clone the extension and the Argon2 Submodule\ngit clone --recursive https://github.com/charlesportwoodii/php-argon2-ext\ncd php-argon2-ext\n\n# Build the Argon2 library\ncd ext/argon2\nCFLAGS=\"-fPIC\" make -j1 OPTTARGET=i686\nmake test\n\n# Remove the argon2 shared library to force Argon2 to be compiled statically into the extension\nrm libargon2.so\ncd ../..\n\n# Build the extension\nphpize\n./configure --with-argon2\nmake\n```\n\n### Installation\n\nOnce you have compiled the extension, you can install it via `make install`, adding the extension to your `php.ini` file or to a file in your loaded extensions directory, \n\n```bash\n$ make install\n# Load the extension to your php.ini/php conf.d\n# echo \"extension=argon2.so\" \u003e /path/to/php.ini\n```\n\n### Testing\n\nExtension is tested through `make test`. You are strongly encouraged to run the tests to make sure everything was built correctly. A summary of the tests will be outlined\n\n```bash\n$ make test\n```\n\nIf `make test` encounters an error, please provide a copy of the error report as a Github issue.\n\n## Usage\n\n### Constants\n\nThe following constants are exposed for determining which Argon2 algorithm you wish to use:\n\n```php\nHASH_ARGON2ID\nHASH_ARGON2I\nHASH_ARGON2D\n```\n\nThe constant `HASH_ARGON2ID` can also be aliased by `HASH_ARGON2`.\n\n\u003e These constants are named to avoid conflicts with https://github.com/php/php-src/pull/1997, which would implement Argon2 in PHP Core.\n\n### Hash Generation\n```php\nargon2_hash(string $string [, const $algorithm = HASH_ARGON2ID] [, array $options ] [, bool $raw = false ]);\n```\n\nHashes can be generated by running `argon2_hash()` with the string you want to see hashed. Without any additional arguements, the hash generated will have the following options. These defaults are based upon the Argon2 specification as good minimums. You are encouraged to run `make bench` against the `ext/argon2` to determine what are good defaults for your system.\n\n```bash\nalgorithm = HASH_ARGON2ID\noptions = [\n    m_cost: 1\u003c\u003c16\n    t_cost: 3\n    threads: 1\n]\n```\n\n\u003e This function follows the same design principles of `password_hash()`, in that a salt will be generated on your behalf. This method does not provide you with a way to provide your own salt. The salt generated uses the native PHP function `php_password_make_salt`, which is the same method used to generate salts for `password_hash()`.\n\nThe `$algorithm` can be changed by passing in either `HASH_ARGON2ID`, `HASH_ARGON2I` or `HASH_ARGON2D`. If the algorithm is invalid, an `InvalidArguementException` will be raised.\n\nThis library allows you to specify an array of options to tune Argon2 to your system. The available options for the `$options` array, and their defaults are defined above. Argon2 has several tolerances in place for each of these values. If the value falls outside those tolerances, and `InvalidArguementException` will be raised.\n\nIn the event an error occurs with the argon2 library, or a salt cannot be securely generated, an `E_WARNING` will be raised, and this will return `false`.\n\nIf no errors occur, an argon2 encoded hash string will be returned.\n\n\u003e This function operates against version 1.3 of the Argon2 library and above.\n\n#### Example Hash\n```php\n$argon2i$v=19$m=65536,t=3,p=1$aUEvQlU2NTRwcHhVS0hqMg$+5h0P5YlWCJDKyZknJ0sAyqQtZjhuP1Bkw/E2It4IcE\n```\n\n\u003e If `$raw` is set to `true`, then this function will return binary output instead. This is useful for Key Derivation Functions (KDF).\n\n### Validating Hashes\n```php\nargon2_verify(string $string, string $hash);\n```\n\nHashes can be verified by running `argon2_verify()` with the string string and string hash generated by `argon2_hash`. This function will return either `true` or `false` depending upon if the hash is valid or not. If the `hash` provided isn't a valid argon2 hash, `false` will be returned, an an `E_WARNING` will be raised.\n\n### Retrieving Hash Information\n```php\nargon2_get_info(string $hash);\n```\n\nTo retrieve information about an existing Argon2 hash, run `argon2_get_info()`. This function will return an array containing the algorithm name, and the options used for hash generation.\n\n```php\narray(2) {\n  [\"algorithm\"]=\u003e\n  string(7) \"argon2i\"\n  [\"options\"]=\u003e\n  array(3) {\n    [\"m_cost\"]=\u003e\n    int(65536)\n    [\"t_cost\"]=\u003e\n    int(3)\n    [\"threads\"]=\u003e\n    int(1)\n  }\n}\n```\n\n## License\n\nBSD-3-Clause. See [LICENSE](LICENSE) for more details.\n\nPHP functions `php_password_make_salt` and `salt_to_base64` are licensed under the PHP License. See http://www.php.net/license/3_01.txt.\n\n\u003e This product includes PHP software, freely available from \u003chttp://www.php.net/software/\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesportwoodii%2Fphp-argon2-ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcharlesportwoodii%2Fphp-argon2-ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcharlesportwoodii%2Fphp-argon2-ext/lists"}