1 unstable release
Uses new Rust 2024
new 0.1.0 | Apr 4, 2025 |
---|
#1030 in Algorithms
104 downloads per month
18KB
329 lines
farmhash-sys
Rust FFI bindings for a minimal implementation of Google's FarmHash hashing algorithms.
Overview
This crate provides low-level Rust bindings to a minimal implementation of Google's FarmHash algorithm. FarmHash is a family of hash functions designed for fast hashing of strings and other data.
The implementation is simplified and optimized for simplicity and ease of use, while still providing the core FarmHash functions:
hash32
- 32-bit hashhash32_with_seed
- 32-bit hash with seedhash64
- 64-bit hashhash64_with_seed
- 64-bit hash with seedhash64_with_seeds
- 64-bit hash with two seedsfingerprint128
- 128-bit fingerprintfingerprint128_with_seed
- 128-bit fingerprint with seed
Usage
Add this to your Cargo.toml
:
[dependencies]
farmhash-sys = "0.1.0"
Example:
use farmhash_sys::farmhash;
fn main() {
let data = b"hello world";
// 32-bit hash
let hash32 = farmhash::hash32(data);
println!("32-bit hash: {}", hash32);
// 64-bit hash
let hash64 = farmhash::hash64(data);
println!("64-bit hash: {}", hash64);
// 128-bit fingerprint
let (low, high) = farmhash::fingerprint128(data);
println!("128-bit fingerprint: ({}, {})", low, high);
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
This is a simplified implementation based on Google's FarmHash algorithm.
Dependencies
~0–2.2MB
~44K SLoC