【代碼】Android SDK平臺獲取高唯一性設備識別碼

注意:由於獲取的設備信息完全可以通過諸如hook攔截等手段僞造,因此不能簡單通過代碼獲取到數據作爲判斷用戶身份的唯一憑據!(某些apk竟然通過imsi,imei來爲用戶自動登錄...)
private static String getUniqueID(Context paramContext)
  {
    for (;;)
    {
      byte[] arrayOfByte;
      int i;
      try
      {
        String str1 = ((TelephonyManager)paramContext.getSystemService("phone")).getDeviceId();
        String str2 = "35" + Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10;
        String str3 = Settings.Secure.getString(paramContext.getContentResolver(), "android_id");
        String str4 = ((WifiManager)paramContext.getSystemService("wifi")).getConnectionInfo().getMacAddress();
        String str5 = str1 + str2 + str3 + str4;
        try
        {
          MessageDigest localMessageDigest2 = MessageDigest.getInstance("MD5");
          localMessageDigest1 = localMessageDigest2;
        }
        catch (NoSuchAlgorithmException localNoSuchAlgorithmException)
        {
          String str7;
          localNoSuchAlgorithmException.printStackTrace();
          MessageDigest localMessageDigest1 = null;
          continue;
        }
        localMessageDigest1.update(str5.getBytes(), 0, str5.length());
        arrayOfByte = localMessageDigest1.digest();
        localObject = new String();
        i = 0;
        if (i >= arrayOfByte.length)
        {
          str7 = ((String)localObject).toUpperCase();
          Log.e("uid", str7);
          return str7;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return "";
      }
      int j = 0xFF & arrayOfByte[i];
      if (j <= 15) {
        localObject = localObject + "0";
      }
      String str6 = localObject + Integer.toHexString(j);
      Object localObject = str6;
      i++;
    }
  }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章