import hashlib
import base64


def create_s256_code_challenge(code_verifier: str) -> str:
    """
    Create S256 code challenge with the passed ``code_verifier``.

    Note:
        This function implements
        ``base64url(sha256(ascii(code_verifier)))``.
    Args:
        code_verifier: Code verifier string.
    Returns:
        Representation of the S256 code challenge with the passed
        ``code_verifier``.
    """
    code_verifier_bytes = code_verifier.encode("utf-8")
    data = hashlib.sha256(code_verifier_bytes).digest()
    return base64.urlsafe_b64encode(data).rstrip(b"=").decode()