Esempio n. 1
0
 /**
  * @param s
  * @return
  */
 public static String mask(final String s) {
   final StringBuffer buffer = new StringBuffer(25);
   final int count = (s != null ? s.length() : 0);
   for (int n = 0; n < count; n++) {
     buffer.append('*');
   }
   return buffer.toString();
 }
Esempio n. 2
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;
    }
  }
Esempio n. 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");
    }
Esempio n. 4
0
  private void goToShowMsg(ShowMessageFromWX.Req showReq) {
    WXMediaMessage wxMsg = showReq.message;
    WXAppExtendObject obj = (WXAppExtendObject) wxMsg.mediaObject;

    StringBuffer msg = new StringBuffer(); // 组织一个待显示的消息内容
    msg.append("description: ");
    msg.append(wxMsg.description);
    msg.append("\n");
    msg.append("extInfo: ");
    msg.append(obj.extInfo);
    msg.append("\n");
    msg.append("filePath: ");
    msg.append(obj.filePath);

    Intent intent = new Intent(this, ShowFromWXActivity.class);
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.STitle, wxMsg.title);
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.SMessage, msg.toString());
    intent.putExtra(net.sourceforge.simcpux.Constants.ShowMsgActivity.BAThumbData, wxMsg.thumbData);
    startActivity(intent);
    // finish();
  }