Add digest support.

This needs to be made much cleaner, but works for now.