def _IsBase64(cls, s):
    """An imperfect but decent method for determining if a string is base64.

    Args:
      s: A string with the data to test.

    Returns:
      True if s is base64, else False.
    """
    try:
      if base64.b64encode(base64.b64decode(s)).decode('utf-8') == s:
        return True
    except (TypeError, binascii.Error):
      pass
    return False
An imperfect but decent method for determining if a string is base64.

    Args:
      s: A string with the data to test.

    Returns:
      True if s is base64, else False.