android 獲取apk簽名的序列號

1.直接從apk上獲取android

將apk後綴改成zip,用WinRAR打開,將META-INF/CERT.RSA解壓出來,好比說解壓到D:\CERT.RSA命令行

命令行底下用code

D:\android\project>keytool -printcert -file "D:\CERT.RSA"ip

就能看到序列號了get


2.代碼中獲取io

try {
       PackageInfo pi = getApplicationContext().getPackageManager().getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
       try {
            X509Certificate certificate = X509Certificate.getInstance(pi.signatures[0].toByteArray());
           
            BigInteger serialBigInteger = certificate.getSerialNumber();
            Log.i(TAG, "" + serialBigInteger.toString(16));
       } catch (CertificateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
       }
  } catch (NameNotFoundException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
  }
相關文章
相關標籤/搜索