# Thread: Putting several hashes together. Better than md5/sha1?

1. ## Putting several hashes together. Better than md5/sha1?

Hi everyone. If I am to example putting several hash function together, would it be as safe as to make an md5 or a sha1 hash? I wonder because I have a program and it generate a md5 hash too slowly. It can only generate up to 20000 hashes (on a laptop) in a second and it is not enough. My idea to fix this is too use several fast hash functions as murmurhash2 and superfasthash, like this:
Code:
```unsigned int* hashes = new unsigned int[2];
hashes[0] = MurmurHash2(str,len);
hashes[1] = SuperFastHash(str,len);```
But is this good in that sense it decrease collision chance than a md5 hash? if I am using a third hash function, would it decrease collision even more? If not, do anyone have any tips on how I can generate a hash fast which have extremely low collision chance?

2. What do you intend to use this hash algorithm for?

EDIT:
Anyway, thinking about it, my guess would be no: if the first hash applied results in a collision, subsequent applications of hash functions will also result in a collision.

3. To hash 8192 bytes and check if (using a multimap) that sequence of bytes have been added before.

4. And you need to do this in 1/2000th of a second EVERY time, or on average? How about if there is a collision, check if it's a match or not, and use some sort of "list" of things with equal hashes.

That way, you deal with collisions, but also get good throughput on most cases.

This doesn't work if you have collisions far too often, or if you can't ever exceed your time-limit (in the later case, "Get a faster machine" is the right solution)!

--
Mats

5. no, only when I am adding data. I do it now, but it is so annoying that the "adding part" of my program is limited to how fast it can make md5 hashes Well, the program will run on a much better machine later so, maybe should I wait to see how good it is performing there before I do some changes ;P

```hashes[0] = MurmurHash2(str,d);