matianfu / xxhash

Automatically exported from code.google.com/p/xxhash
Other
0 stars 0 forks source link

Unfeeding #5

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This may be a stupid question, but would it be possible to 'unfeed' bytes from 
the hash? One application would be to create a rolling hash over the last n 
bytes.

Original issue reported on code.google.com by fha...@gmail.com on 25 Mar 2013 at 4:22

GoogleCodeExporter commented 9 years ago
I feel not, at least not in a generic way.
After data is fed, internal states are scrambled in a way to make them look 
random. Going back to previous value is almost impossible.

Now there is indeed a possibility for xxHash in particular, but it is limited.
Due to the way the intermediate buffer works, it would be possible to cancel 
the last N-byte, as long it doesn't cross a "multiple of 16" value.
So, for example, if 33 bytes were fed into xxHash, it would be possible to 
cancel the last one (1) byte, but not 2. 

More importantly, it's also not possible to remove bytes at the beginning of 
the sequence. With regards to the application you're looking for, i believe 
there are much better (and faster) ressources over Internet to code a rolling 
hash. Rolling hashes have mathematic properties specifically dedicated to 
erasing bytes at the beginning of the sequence.

Original comment by yann.col...@gmail.com on 25 Mar 2013 at 4:39

GoogleCodeExporter commented 9 years ago
Thanks for the quick response.

Could you perhaps propose some keywords related to this kind of algorithm?
Searching for "running hash [algorithm]" or "windowed hash [algorithm]"
does not yield any useful results.

Original comment by fha...@gmail.com on 25 Mar 2013 at 5:39

GoogleCodeExporter commented 9 years ago

Original comment by yann.col...@gmail.com on 25 Mar 2013 at 5:41