import hashlib


def hash_value(_ctx, value, algorithm='sha'):
    """Hash the value using the algorithm."""
    if algorithm in ('md5',):
        return hashlib.md5(value).hexdigest()
    if algorithm in ('sha1',):
        return hashlib.sha1(value).hexdigest()
    if algorithm in ('sha224',):
        return hashlib.sha224(value).hexdigest()
    if algorithm in ('sha384',):
        return hashlib.sha384(value).hexdigest()
    if algorithm in ('sha512',):
        return hashlib.sha512(value).hexdigest()
    return hashlib.sha256(value).hexdigest()