获取当前app的签名信息

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

    /** 
     * get signature of current package 
     * @param context 
     * @return signature, null if there is no signature 
     */  
    public static String getSignature(Context context){  
      
        Log.i(TAG, "SignatureUtils.getSignature");  
      
        PackageManager pm = context.getPackageManager();  
        String pkgName = context.getPackageName();  
      
        try {  
            PackageInfo pi = pm.getPackageInfo(pkgName, PackageManager.GET_SIGNATURES);  
            Signature[] signatures = pi.signatures;  
      
            if(signatures != null && signatures.length > 0){  
      
                String signature =  signatures[0].toCharsString();  
                Log.i(TAG, "Signature of current package is : " + signature);  
      
                return  signature;  
            }  
        } catch (PackageManager.NameNotFoundException e1) {  
            e1.printStackTrace();  
        }  
      
        return null;  
    }