{"id":15029786,"url":"https://github.com/rancoud/crypt","last_synced_at":"2025-04-09T20:40:29.446Z","repository":{"id":37579879,"uuid":"119200475","full_name":"rancoud/Crypt","owner":"rancoud","description":"Crypt Package","archived":false,"fork":false,"pushed_at":"2025-04-01T12:19:14.000Z","size":468,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T13:27:35.354Z","etag":null,"topics":["argon2i","argon2id","bcrypt","composer","coverage","crypt","cryptography","hash","packagist","php","php74","php8","php80","php81","phpunit","phpunit9"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/rancoud/crypt","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/rancoud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-27T20:34:34.000Z","updated_at":"2025-04-01T12:19:16.000Z","dependencies_parsed_at":"2023-10-02T12:19:01.779Z","dependency_job_id":"0d37208f-9b82-4d18-9dd7-222b84b7e065","html_url":"https://github.com/rancoud/Crypt","commit_stats":{"total_commits":132,"total_committers":3,"mean_commits":44.0,"dds":"0.38636363636363635","last_synced_commit":"0740a28f817a472a1a724c19f2305742d0817647"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FCrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FCrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FCrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rancoud%2FCrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rancoud","download_url":"https://codeload.github.com/rancoud/Crypt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248109612,"owners_count":21049343,"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":["argon2i","argon2id","bcrypt","composer","coverage","crypt","cryptography","hash","packagist","php","php74","php8","php80","php81","phpunit","phpunit9"],"created_at":"2024-09-24T20:11:37.603Z","updated_at":"2025-04-09T20:40:29.438Z","avatar_url":"https://github.com/rancoud.png","language":"PHP","readme":"# Crypt Package\n\n![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/rancoud/crypt)\n[![Packagist Version](https://img.shields.io/packagist/v/rancoud/crypt)](https://packagist.org/packages/rancoud/crypt)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/rancoud/crypt)](https://packagist.org/packages/rancoud/crypt)\n[![Composer dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://github.com/rancoud/Crypt/blob/master/composer.json)\n[![Test workflow](https://img.shields.io/github/actions/workflow/status/rancoud/crypt/test.yml?branch=master)](https://github.com/rancoud/crypt/actions/workflows/test.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/rancoud/crypt?logo=codecov)](https://codecov.io/gh/rancoud/crypt)\n\nCrypt using Argon2id by default with Argon2i and bcrypt in fallback.  \n\n## Installation\n```php\ncomposer require rancoud/crypt\n```\n\n## How to use it?\n```php\nuse Rancoud\\Crypt\\Crypt;\n\n$password = 'my_password';\n$hash = Crypt::hash($password);\n$result = Crypt::verify($password, $hash);\n\n// use only Argon2i\nCrypt::useArgon2i();\n\n// use only bcrypt\nCrypt::useBcrypt();\n```\n\n## Crypt\n### Main functions\nHashs the password according to the selected algorithm.\n```php\npublic static function hash(string $password): string\n```\n\nChecks whether the hash needs to be rehash to match the selected algorithm and options.\n```php\npublic static function needsRehash(string $hash): bool\n```\n\nChecks if password and hash match.\n```php\npublic static function verify(string $password, string $hash): bool\n```\n\n### Algorithms\nReturns current algorithm.  \nPossible values are `argon2id`, `argon2i` or `2y`.\n```php\npublic static function getCurrentAlgo(): string\n```\n\nSets the algorithm to `argon2id`.\n```php\npublic static function useArgon2id(): void\n```\n\nSets the algorithm to `argon2i`.\n```php\npublic static function useArgon2i(): void\n```\n\nSets the algorithm to `2y` (bcrypt).\n```php\npublic static function useBcrypt(): void\n```\n\n### Options\nSets memory cost for `argon2id` and `argon2i`.\u003cbr\u003e\nMust be equal or greater than 8.\n```php\npublic static function setOptionArgon2iMemoryCost(int $bytes): void\n```\n\nSets number of threads for `argon2id` and `argon2i`.\u003cbr\u003e\nMust be equal or greater than 1.\n```php\npublic static function setOptionArgon2iThreads(int $threads): void\n```\n\nSets time cost for `argon2id` and `argon2i`.\u003cbr\u003e\nMust be equal or greater than 1.\n```php\npublic static function setOptionArgon2iTimeCost(int $time): void\n```\n\nSets rounds cost for `2y` (bcrypt).\u003cbr\u003e\nMust be between 4 and 31.\n```php\npublic static function setOptionBcryptCost(int $rounds): void\n```\n\nReturns options for `argon2id` and `argon2i`.\n```php\npublic static function getOptionsArgon2i(): array\n```\n\nReturns options for `2y` (bcrypt).\n```php\npublic static function getOptionsBcrypt(): array\n```\n\n### Random string\nReturns a fixed-size string containing random characters from the preselection.  \nThe default character pool is `!\"#$%\u0026\\'()*+,-./0123456789:;\u003c=\u003e?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_``abcdefghijklmnopqrstuvwxyz{|}~`.\n```php\npublic static function getRandomString(int $length = 64, ?string $characters = null): string\n```\n\nReturns the character pool.\n```php\npublic static function getCharactersForRandomString(): string\n```\n\nSets the character pool.\n```php\npublic static function setCharactersForRandomString(string $characters): void\n```\n\n## How to Dev\n`composer ci` for php-cs-fixer and phpunit and coverage  \n`composer lint` for php-cs-fixer  \n`composer test` for phpunit and coverage\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francoud%2Fcrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Francoud%2Fcrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Francoud%2Fcrypt/lists"}