{"id":15524263,"url":"https://github.com/exussum12/xxhash","last_synced_at":"2025-04-16T05:01:50.280Z","repository":{"id":46318232,"uuid":"135839887","full_name":"exussum12/xxhash","owner":"exussum12","description":"a xxhash implementation in php","archived":false,"fork":false,"pushed_at":"2021-10-30T22:55:38.000Z","size":45,"stargazers_count":21,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T05:03:02.794Z","etag":null,"topics":["hacktoberfest","php","xxhash"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/exussum12.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-02T17:51:27.000Z","updated_at":"2025-03-06T23:11:30.000Z","dependencies_parsed_at":"2022-08-20T12:01:15.138Z","dependency_job_id":null,"html_url":"https://github.com/exussum12/xxhash","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exussum12%2Fxxhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exussum12%2Fxxhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exussum12%2Fxxhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/exussum12%2Fxxhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/exussum12","download_url":"https://codeload.github.com/exussum12/xxhash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249199767,"owners_count":21228994,"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":["hacktoberfest","php","xxhash"],"created_at":"2024-10-02T10:50:16.866Z","updated_at":"2025-04-16T05:01:50.232Z","avatar_url":"https://github.com/exussum12.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"A pure PHP implementation of [xxhash](https://github.com/Cyan4973/xxHash)\n\nCurrently only working for the 32 bit version. (Pre PHP 7.4). 32 and 64 bit version both work with PHP 7.4\n\nIf speed is important use the FFI versions (PHP 7.4+)\n\nXXHash is a fast hash designed for file integrity checking. Passwords should not be hashed with this, please use Argon2 or BCrypt.\n\nOn PHP 8.1 xxhash is included by default, please use that instead\n\n    hash('xxh32',  'string');\n\nfor string mode or\n\n    $context = hash_init('xxh3');\n    hash_update($context, 'String1'); // from fgets or similar\n    hash_update($context, 'String2'); // from fgets or similar\n    hash_final($context);\n\n# Installing\n\nWith composer \n\n    composer require exussum12/xxhash\n\n# Hashing input\n\nxxhash has a seed, this is 0 by default. To make a new instance of xxhash run\n\n    use exussum12\\xxhash\\V32;\n    $seed = 0;\n    $hash = new V32($seed);\n\nThen to hash input, run\n\n    $hash-\u003ehash('string'); ## to hash a string\n \n or\n \n    $file = fopen('path/to/file.ext', 'r');\n    $hash-\u003ehashStream($file); # for a stream (better for large files)\n\nThe library can be called statically also, however this removes the ability to change the seed. The default see of 0 will be used\n\n    V32::hash('string'); ## to hash a string\n    $file = fopen('path/to/file.ext', 'r');\n    V32::hashStream($file); # for a stream (better for large files)\n\nStatic functions should in general be avoided, so the first method is the preferred method to use.\n\n## FFI\nSince PHP 7.4 FFI allows PHP to call the native C client. This is much faster, and the preferred way if your running PHP 7.4\n\n### Speed Comparison\nThis is hashing a 320mb file using the stream method.\nThe time is the time take (smaller is better)\n\n|Method       |Time  | Peak Memory |\n|-------------|------|-------------|\n|xxHash Binary| 0.081|       1604kb|\n|FFI          | 0.194|      27616kb|\n|Pure PHP     |49.218|      27844kb|\n\nMemory measured using `/usr/bin/time -v` \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexussum12%2Fxxhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexussum12%2Fxxhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexussum12%2Fxxhash/lists"}