Palace Chan
Palace Chan

Reputation: 9213

What does it mean for a hash function to be incremental?

I have heard that, for example, MurmurHash2 is not "incremental" but MurmurHash3 is incremental. What does this mean? And why is it useful?

Upvotes: 15

Views: 9478

Answers (2)

Rotsor
Rotsor

Reputation: 13793

MurmurHash3 is not incremental in the sense tommarshall describes.

When people describe it as incremental they mean that you can compute hash of a stream in O(1) memory, i.e. you can have an API that let you do the following (in pseudocode):

x = Hasher()
x.add("hello ")
x.add("world!")
x.get_hash()

and that would produce a hash of string "hello world" without keeping the whole string in memory at any point in time.

In particular, the imurmurhash-js javascript package uses the word 'incremental' in that meaning.

Same meaning is used in MetroHash docs.

Upvotes: 5

tommarshall
tommarshall

Reputation: 2128

Incremental hash functions suited for situations where if a previously hashed message, M is slightly updated into a new message, M*, then it should be fairly quick to compute the hash value of the updated message, M*. This is done by computing the new hash, m*, from the old hash value, m, in contrast to conventional hash functions that have to recompute the new hash, m* from scratch, which takes a longer time.

http://www.cs.berkeley.edu/~daw/papers/inchash-cs06.pdf

They're useful due to the fact that they're easier to compute and therefore less expensive in terms of computing power and time.

However they're not suited to every situation. That paper from Berkeley has some nice examples of when they can be useful in the Introduction section.

Upvotes: 10

Related Questions