def normalized_digest(digest, digest_type='sha512'):
    """Normalize the digest to return version that enables string comparison.

    All forms (except the spec example forms) are case insensitive. We
    use lowercase as the normalized form.
    """
    if digest_type in ('sha512-spec-ex', 'sha256-spec-ex'):
        return digest
    return digest.lower()