A rolling hash (recursive hashing or rolling checksum) is a hash function where the input is hashed in a window that moves through the input.
A few hash functions allow a rolling hash to be computed very quickly—the new hash value is rapidly calculated given only the old hash value, the old value removed from the window, and the new value added to the window—similar to the way a moving average function can be computed much more quickly than other low-pass filters.
Rabin–Karp rolling hash
The Rabin–Karp string search algorithm is normally used with a very simple rolling hash function that only uses multiplications and additions:
Code to generate Rolling Hash