Generalise digest_algorithm to crypto_algorithm.