{"id":22760852,"url":"https://github.com/thevilledev/chibihash-rs","last_synced_at":"2025-04-14T19:20:19.010Z","repository":{"id":263635416,"uuid":"891017449","full_name":"thevilledev/ChibiHash-rs","owner":"thevilledev","description":"ChibiHash in Rust - a small, fast 64-bit hash function","archived":false,"fork":false,"pushed_at":"2025-01-08T08:28:23.000Z","size":58,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T13:59:37.669Z","etag":null,"topics":["hash-functions","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/chibihash","language":"Rust","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/thevilledev.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":"2024-11-19T15:27:14.000Z","updated_at":"2025-01-14T18:02:49.000Z","dependencies_parsed_at":"2024-11-19T16:42:40.847Z","dependency_job_id":"a6911e5b-48cc-44b4-9ac1-32b7d7b00dac","html_url":"https://github.com/thevilledev/ChibiHash-rs","commit_stats":null,"previous_names":["thevilledev/chibihash-rs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thevilledev%2FChibiHash-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thevilledev%2FChibiHash-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thevilledev%2FChibiHash-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thevilledev%2FChibiHash-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thevilledev","download_url":"https://codeload.github.com/thevilledev/ChibiHash-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248943428,"owners_count":21186958,"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-functions","rust"],"created_at":"2024-12-11T09:08:44.189Z","updated_at":"2025-04-14T19:20:18.990Z","avatar_url":"https://github.com/thevilledev.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChibiHash-rs\n\n[\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/chibihash.svg?style=for-the-badge\u0026color=fc8d62\u0026logo=rust\" height=\"20\"\u003e](https://crates.io/crates/chibihash)\n[\u003cimg alt=\"docs.rs\" src=\"https://img.shields.io/badge/docs.rs-chibihash-66c2a5?style=for-the-badge\u0026labelColor=555555\u0026logo=docs.rs\" height=\"20\"\u003e](https://docs.rs/chibihash)\n[\u003cimg alt=\"build status\" src=\"https://img.shields.io/github/actions/workflow/status/thevilledev/chibihash-rs/test.yml?branch=main\u0026style=for-the-badge\" height=\"20\"\u003e](https://github.com/thevilledev/chibihash-rs/actions?query=branch%3Amain)\n\nRust port of [N-R-K/ChibiHash](https://github.com/N-R-K/ChibiHash). See the article [ChibiHash: A small, fast 64-bit hash function](https://nrk.neocities.org/articles/chibihash) for more information.\n\nAll credit for the algorithm goes to [N-R-K](https://github.com/N-R-K).\n\n## Versioning\n\nSince crate version `0.4.0` the crate offers two versions of the algorithm:\n\n- `v1` is the original implementation and the default one.\n- `v2` is a new implementation with better performance and passes all tests in [smhasher3](https://github.com/rurban/smhasher/tree/master/smhasher3).\n\nIf you import the crate without any version specifier, the `v1` version is used.\nThe `v1` version can also be explicitly selected by importing `chibihash::v1::*` instead.\n\nIf you want the latest and greatest version, you can import `chibihash::v2::*`.\n\nThe `v2` version will be the default in the next major version.\n\n## Features\n\n- 64-bit hash function\n- Deterministic\n- Fast\n- No dependencies\n- `no-std` compatible\n- Multiple ways to use ChibiHash:\n  1. **Direct Hashing**: One-shot hashing using `chibi_hash64()`\n  2. **Simple Hasher**: Basic implementation using `ChibiHasher` (implements `std::hash::Hasher`)\n  3. **Streaming Hasher**: Memory-efficient streaming with `StreamingChibiHasher` (implements `std::hash::Hasher`)\n  4. **BuildHasher**: `ChibiHasher` implements `BuildHasher`. This allows using ChibiHash as the default hasher for `std::collections::HashMap` and `std::collections::HashSet`. Use `ChibiHashMap` and `ChibiHashSet` types.\n\n## Example\n\n```rust\nuse chibihash::{chibi_hash64, ChibiHasher, StreamingChibiHasher, ChibiHashMap, ChibiHashSet};\nuse std::hash::Hasher;\n\nfn main() {\n    // Method 1: Direct hashing\n    let hash = chibi_hash64(b\"yellow world\", 42);\n    println!(\"Direct hash: {:016x}\", hash);\n\n    // Method 2: Using Hasher trait\n    let mut hasher = ChibiHasher::new(42);\n    hasher.write(b\"yellow world\");\n    println!(\"Hasher trait: {:016x}\", hasher.finish());\n\n    // Method 3: Streaming hashing\n    let mut hasher = StreamingChibiHasher::new(0);\n    hasher.update(b\"yellow \");\n    hasher.update(b\"world\");\n    println!(\"Streaming: {:016x}\", hasher.finalize());\n\n    // Method 4: BuildHasher for HashMap\n    let mut map: ChibiHashMap\u003cString, i32\u003e = ChibiHashMap::default();\n    map.insert(\"hello\".to_string(), 42);\n    println!(\"BuildHasher HashMap: {:?}\", map.get(\"hello\"));\n\n    // Method 5: BuildHasher for HashSet\n    let mut set: ChibiHashSet\u003cString\u003e = ChibiHashSet::default();\n    set.insert(\"hello\".to_string());\n    println!(\"BuildHasher HashSet: {}\", set.contains(\"hello\"));\n\n}\n```\n\n## Tests\n\nRun `cargo test` to see the tests.\n\n## Benchmarks\n\nRun `cargo bench` to see the benchmarks. See `target/criterion/report/index.html` for the HTML report.\n\nThe repository also contains a benchmark comparing the Rust implementation to the C implementation. Run `cargo bench --features ffi` to see the benchmark. The C version can be found from the `csrc` directory. The benchmark utilises FFI to call the C version.\n\nBased on limited testing, the pure Rust implementation is faster than the C version when the input sizes are small (below 1024 bytes). With larger input sizes they are equal. Possibly due to the overhead of the FFI interface itself.\n\n## When not to use ChibiHash\n\nCopy-paste from the original repository. Same applies here.\n\n\u003eHere are some reasons to avoid using this:\n\u003e\n\u003e* For cryptographic purposes.\n\u003e* For protecting against [collision attacks](https://en.wikipedia.org/wiki/Collision_attack) (SipHash is the recommended one for this purpose).\n\u003e* When you need very strong probability against collisions: ChibiHash does very\n\u003e  minimal amount of mixing compared to other hashes (e.g xxhash64). And so\n\u003e  chances of collision should in theory be higher.\n\n## License\n\nMIT. The original C version is under the Unlicense.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthevilledev%2Fchibihash-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthevilledev%2Fchibihash-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthevilledev%2Fchibihash-rs/lists"}