1. A method for producing a message hash, comprising: segmenting a message into an sequence of blocks; accessing an integer g, wherein p is a prime number, q is a prime not equal to 2 that divides p−1 and g is a generator of a subgroup, with order q, of the group of integers less than p; initializing a first intermediate hash value based on a first block of the sequence; for the remaining blocks in the sequence, initializing a respective intermediate hash value, selecting a number of integers from the subgroup generated by g, adding each of the integers to the intermediate hash value, and reducing the sum modulo a value related to p, wherein the number of integers selected for each block depends on the intermediate hash value of the prior block, and the selection of the integers is based at least on a value of the current block of the message; and returning a value derived from a selection of bits at least from the last-produced intermediate hash as the message hash.