docs: def encrypt_variable(variable, build_repo, *, tld='.org', public_key=None,
      travis_token=None, **login_kwargs):
      """
      Encrypt an environment variable for ``build_repo`` for Travis
  
      ``variable`` should be a bytes object, of the form ``b'ENV=value'``.
  
      ``build_repo`` is the repo that ``doctr deploy`` will be run from. It
      should be like 'drdoctr/doctr'.
  
      ``tld`` should be ``'.org'`` for travis-ci.org and ``'.com'`` for
      travis-ci.com.
  
      ``public_key`` should be a pem format public key, obtained from Travis if
      not provided.
  
      If the repo is private, travis_token should be as returned by
      ``get_temporary_token(**login_kwargs)``. A token being present
      automatically implies ``tld='.com'``.
  
      """
      if not isinstance(variable, bytes):
          raise TypeError("variable should be bytes")
  
      if not b"=" in variable:
          raise ValueError("variable should be of the form 'VARIABLE=value'")
  
      if not public_key:
          _headers = {
              'Content-Type': 'application/json',
              'User-Agent': 'MyClient/1.0.0',
          }
          headersv2 = {**_headers, **Travis_APIv2}
          headersv3 = {**_headers, **Travis_APIv3}
          if travis_token:
              headersv3['Authorization'] = 'token {}'.format(travis_token)
              res = requests.get('https://api.travis-ci.com/repo/{build_repo}/key_pair/generated'.format(build_repo=urllib.parse.quote(build_repo,
                  safe='')), headers=headersv3)
              if res.json().get('file') == 'not found':
                  raise RuntimeError("Could not find the Travis public key for %s" % build_repo)
              public_key = res.json()['public_key']
          else:
              res = requests.get('https://api.travis-ci{tld}/repos/{build_repo}/key'.format(build_repo=build_repo,
                                                                                            tld=tld),
                                 headers=headersv2)
              public_key = res.json()['key']
  
          if res.status_code == requests.codes.not_found:
              raise RuntimeError('Could not find requested repo on Travis.  Is Travis enabled?')
              res.raise_for_status()
  
      public_key = public_key.replace("RSA PUBLIC KEY", "PUBLIC KEY").encode('utf-8')
      key = serialization.load_pem_public_key(public_key, backend=default_backend())
  
      pad = padding.PKCS1v15()
  
      return base64.b64encode(key.encrypt(variable, pad))