Move digest calculation to a separate method.