def left_hash(msg, func="HS256"):
    """ Calculate left hash as described in
    https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken
    for at_hash and in
    for c_hash

    :param msg: The message over which the hash should be calculated
    :param func: Which hash function that was used for the ID token
    """
    if func == 'HS256':
        return as_unicode(b64e(sha256_digest(msg)[:16]))
    elif func == 'HS384':
        return as_unicode(b64e(sha384_digest(msg)[:24]))
    elif func == 'HS512':
        return as_unicode(b64e(sha512_digest(msg)[:32]))