Can't get MD5 crate to work

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cc57b73fc7fef1d0b4e95139b9b43c9d

I can't get the standard MD5 crate to import properly. The example on cargo.io won't even work in Playground, even though Playground has the crate. I've tried the obvious variations on extern crate, use, etc. I have to be doing something dumb here. But what?

The playground has version 0.7.0 of the md5 crate, and in that version the struct you are looking for is called Context.

Note that it also has an md5::compute helper function for when the full data fits in a single slice.

2 Likes

I don't see the example from your playground on https://crates.io/crates/md5 -- where did you get it?

From here: md5 - Rust

Interesting, that's a different crate — md-5 not md5. If you're importing md5 on the playground that would explain why example code for md-5 doesn't compile (and vice versa of course).

Right. I switched to SHA3-256, anyway. I just need a long hash so I can un-duplicate graphics meshes without actually storing them.

1 Like

If you don't need compatibility with the "classic" hash algorithms, then try BLAKE3:

1 Like

Blake3 - that's useful, thanks.

Out of curiosity, is it important to use a crypto-strength hash function in this case? If not, are there non-cryptographic hash functions that produce long (e.g. 256 bits) digests and can be computed significantly faster than BLAKE3 or SHA3-256?

Apparently, yes ! There are some non-cryptographic hash functions that can produce 256 bit and even larger hashes:

I don't know about the performance difference though BLAKE3 is also very fast, you'd have to benchmark.

It would be useful to be able to Derive a unique long hash for a struct, for the uses above. Does anything like that exist?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.