import base64


def bytes_to_b64(value: bytes, urlsafe=False) -> str:
    """Convert a byte string to base 64.

    :param value: (bytes) input bytes array
    :param urlsafe: (bool) flag if needed to convert to urlsafe presentation
    :return base64 presentation
    """
    if urlsafe:
        return base64.urlsafe_b64encode(value).decode("ascii")
    else:
        return base64.b64encode(value).decode("ascii")