示例#1
0
  private boolean obbIsCorrupted(String f, String main_pack_md5) {

    try {

      InputStream fis = new FileInputStream(f);

      // Create MD5 Hash
      byte[] buffer = new byte[16384];

      MessageDigest complete = MessageDigest.getInstance("MD5");
      int numRead;
      do {
        numRead = fis.read(buffer);
        if (numRead > 0) {
          complete.update(buffer, 0, numRead);
        }
      } while (numRead != -1);

      fis.close();
      byte[] messageDigest = complete.digest();

      // Create Hex String
      StringBuffer hexString = new StringBuffer();
      for (int i = 0; i < messageDigest.length; i++) {
        String s = Integer.toHexString(0xFF & messageDigest[i]);

        if (s.length() == 1) {
          s = "0" + s;
        }
        hexString.append(s);
      }
      String md5str = hexString.toString();

      // Log.d("GODOT","**PACK** - My MD5: "+hexString+" - APK md5: "+main_pack_md5);
      if (!md5str.equals(main_pack_md5)) {
        Log.d(
            "GODOT",
            "**PACK MD5 MISMATCH???** - MD5 Found: "
                + md5str
                + " "
                + Integer.toString(md5str.length())
                + " - MD5 Expected: "
                + main_pack_md5
                + " "
                + Integer.toString(main_pack_md5.length()));
        return true;
      }
      return false;
    } catch (Exception e) {
      e.printStackTrace();
      Log.d("GODOT", "**PACK FAIL**");
      return true;
    }
  }
 private String debugVersions() {
   StringBuffer sb = new StringBuffer();
   sb.append("bot=");
   sb.append(bottom);
   sb.append(" top=");
   sb.append(top);
   sb.append(" [");
   for (int i = 0; i < versions.size(); i++) {
     if (i > 0) sb.append(" ");
     sb.append(versions.get(i).version);
   }
   sb.append("]");
   return sb.toString();
 }
示例#3
0
    public HTTPStream(HttpURLConnection connection_, int[] statusCode, StringBuffer responseHeaders)
        throws IOException {
      connection = connection_;

      try {
        inputStream = new BufferedInputStream(connection.getInputStream());
      } catch (IOException e) {
        if (connection.getResponseCode() < org.apache.http.HttpStatus.SC_BAD_REQUEST) throw e;
      } finally {
        statusCode[0] = connection.getResponseCode();
      }

      if (statusCode[0] >= org.apache.http.HttpStatus.SC_BAD_REQUEST)
        inputStream = connection.getErrorStream();
      else inputStream = connection.getInputStream();

      for (java.util.Map.Entry<String, java.util.List<String>> entry :
          connection.getHeaderFields().entrySet())
        if (entry.getKey() != null && entry.getValue() != null)
          responseHeaders.append(
              entry.getKey() + ": " + android.text.TextUtils.join(",", entry.getValue()) + "\n");
    }