Change digest() code so it can be called multiple times at different
points