Skip to content

Simple non-cryptographic hash function in Rust with SIMD optimization

License

Notifications You must be signed in to change notification settings

s0uthview/fernhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fernhash

fernhash is a simple, fast, non-cryptographic, SIMD-optimized hash function implemented in Rust. It is suitable for hash maps, checksums, and your general data needs.

⚠️ Warning! Fernhash is not cryptographically secure. Do not use it for passwords, signatures, or any cryptographic purposes.

Features

  • Optimized for small and large inputs
  • On x86_64, SIMD accelerated with AVX2
  • Support for custom seeds
  • Implements std::hash::Hasher and BuildHasher
  • Useful for HashMap/HashSet key hashing

Installation

Add to your Cargo.toml:

fernhash = { git = "github.com/s0uthview/fernhash" }

Usage

Hash function:

use fernhash::fernhash;

let data = b"Hello, world!";
let seed = 42;
let hash = fernhash(data, seed);

println!("Hash: {:?}", hash);

With a HashMap

use fernhash::BuildFernHasher;
use std::collections::HashMap;

let mut map: HashMap<&str, u64, BuildFernHasher> =
    HashMap::with_hasher(BuildFernHasher::new());
map.insert("key", 123);
println!("Value: {:?}", map.get("key"));

Feel free to check out the examples folder to get a better feel for the crate. I think ferns are really cool plants :>

About

Simple non-cryptographic hash function in Rust with SIMD optimization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages