{"id":24800090,"url":"https://github.com/simdhash/clhash","last_synced_at":"2025-04-07T06:12:12.903Z","repository":{"id":66054821,"uuid":"57042471","full_name":"simdhash/clhash","owner":"simdhash","description":"C library implementing the ridiculously fast CLHash  hashing function","archived":false,"fork":false,"pushed_at":"2024-04-04T02:34:39.000Z","size":29,"stargazers_count":274,"open_issues_count":3,"forks_count":29,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-31T05:03:46.406Z","etag":null,"topics":["hash","hashing"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simdhash.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":"2016-04-25T13:08:28.000Z","updated_at":"2025-03-28T04:56:25.000Z","dependencies_parsed_at":"2024-10-26T20:28:58.188Z","dependency_job_id":"829e499d-8abf-4c2e-8ffa-ac281b589398","html_url":"https://github.com/simdhash/clhash","commit_stats":null,"previous_names":["simdhash/clhash"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simdhash%2Fclhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simdhash%2Fclhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simdhash%2Fclhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simdhash%2Fclhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simdhash","download_url":"https://codeload.github.com/simdhash/clhash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601449,"owners_count":20964864,"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":["hash","hashing"],"created_at":"2025-01-30T03:09:13.831Z","updated_at":"2025-04-07T06:12:12.870Z","avatar_url":"https://github.com/simdhash.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clhash\n\nC library implementing the ridiculously fast CLHash hashing function (with C++ wrappers)\n\n\n CLHash is a very fast hashing function that uses the\n carry-less multiplication and SSE instructions.\n Best used on recent x64 processors (Haswell or better).\n\nCLHash has the following characteristics :\n\n* On a recent Intel processor (e.g., Skylake), it can hash input strings at a speed of 0.1 cycles per byte for sufficiently long strings. You read this right: it is simply ridiculously fast.\n* It has strong theoretical guarantees: XOR universality of short strings and excellent almost universality for longer strings.\n\nFor details, please see the research article:\n\nDaniel Lemire, Owen Kaser, Faster 64-bit universal hashing using carry-less multiplications, Journal of Cryptographic Engineering 6 (3), 2016. http://arxiv.org/abs/1503.03465\n\n## Requirements\n\n\nPlease do not try to compile and run this software on legacy hardware (x64 processors\nbefore Haswell), it will either fail to work or be slow. It should be able to port\nthe code to other architectures such as ARM or POWER processors but performance is\nunknown at this point. And, yes, this means that CLHash is *not* portable hardware-wise.\n\nIf your compiler is not C99 compliant... please get better one.\n\nIf your applications requires hashing tiny strings, then you will not get a speed close to 0.1 cycles per byte. \nThe string should be significantly several times larger than a vector register (128 bits). So clhash is not\nmeant to be a general-purpose hash function.\n\n\n## Usage\n\n ```bash\n make\n ./unit\n ```\nCompile option: if you define BITMIX during compilation, extra work is done to\npass smhasher's avalanche test succesfully. Disabled by default.\n\n## Code sample\n\n```C\n#include \u003cassert.h\u003e\n\n#include \"clhash.h\"\n\nint main() {\n    void * random =  get_random_key_for_clhash(UINT64_C(0x23a23cf5033c3c81),UINT64_C(0xb3816f6a2c68e530));\n    uint64_t hashvalue1 = clhash(random,\"my dog\",6);\n    uint64_t hashvalue2 = clhash(random,\"my cat\",6);\n    uint64_t hashvalue3 = clhash(random,\"my dog\",6);\n    assert(hashvalue1 == hashvalue3);\n    assert(hashvalue1 != hashvalue2);// very likely to be true\n    free(random);\n    return 0;\n}\n```\n\n## Simple benchmark\n\n ```bash\n make\n ./benchmark\n ```\n\n ## C++\n\nIf you prefer the convenience of a C++ interface with support for stl::vector and std::string,\nyou can create a clhasher object instead.\n\n```C\n#include \u003cassert.h\u003e\n#include \u003ccstdio\u003e\n#include \u003cvector\u003e\n\n#include \"clhash.h\"\n\n\nint main(void) {\n    clhasher h(UINT64_C(0x23a23cf5033c3c81),UINT64_C(0xb3816f6a2c68e530));\n    std::vector\u003cint\u003e vec{1,3,4,5,2,24343};\n    uint64_t vechash = h(vec);\n\n    uint64_t arrayhash = h(vec.data(), vec.size());\n\n    assert(vechash == arrayhash);\n\n    uint64_t cstringhash = h(\"o hai wurld\");\n    uint64_t stringhash = h(std::string(\"o hai wurld\"));\n    assert(cstringhash == stringhash);\n}\n```\n\n ```bash\n make\n ./cppunit\n ```\n\n\nCredit for C++ wrapper: Daniel Baker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimdhash%2Fclhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimdhash%2Fclhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimdhash%2Fclhash/lists"}