New sys crate : cityhash-sys

Hello Rustaceans,

I would like to share with you my first public crate :tada: cityhash-sys.

It's a fully tested and documented Rust bindings of the Google CityHash C algorithms including 32, 68, 128 and 256 hash and x86_64 CRC32 intrinsic versions.

As I'm primarily a C++ programmer, feel free to report errors, better practice, etc...

1 Like

That seems like a great addition to crates.io :slight_smile:

As feedback, I think most hash crates present an interface either implementing the core::hash::Hasher, or (depending on intent) one of the traits from the RustCrypto project. (here it seems to be a hash for hashtables ? so that would probably be the core Hasher trait)

In particular I don't see any way to stream the hashing in the docs. Edit : that seems to be a limitation of the algorithm here, they have an issue opened on this subject since 2014.

A few examples from other crates in no particular order : metrohash, highway, twox-hash, fnv. The FnvHasher might be the most canonical example.

2 Likes

Thanks for your feedback,

I will take a look at core::hash::Hasher !
CityHash is not suitable for cryptography, I will not add RustCrypto trait implementation.

Be sure to also look at the doc for BuildHasherDefault to see how you can provide an easy way to inject your hasher into a hashmap. And look at the type definitions in the other crates to see how they did their own HasherBuilder.

1 Like

A new version of the crate include the BuildHasherDefault. It provides 3 hashers ( 32-bits, 64-bits and 128-bits hashers).

1 Like

We can stream for 64-bits and 128-bits with the seeds functions. 32-bits do not have seed version, but the combinaison of the 2 32-bits hash can be done with Murmur3 combinaison as CityHash is based on Murmur3.