The Rabin-Karp algorithm can be used to calculated the rolling hash values of consecutive sub strings in a whole sequence.

For instance, we have a sequence S, whose length is N, and we want to extract the hash values for all the substrings of length k.