Calculate hash for header