This is based on the git SHA1 implementation and optimized to do word accesses rather than byte accesses, and to avoid unnecessary copies into the context array.