码迷,mamicode.com
首页 > 其他好文 > 详细

查看apk的sha1值以及apk信息

时间:2015-04-20 14:58:51      阅读:629      评论:0      收藏:0      [点我收藏+]

标签:

1 查看apk的sha1值  

  有时,希望查看到对应签名了的apk文件的sha1值。使用下面脚本,脚本文件为showInfo.sh :

#!/bin/bash  
get_signature() {  
    path=`jar tf "$1" | grep RSA` 
    jar xf $1 $path 
    keytool -printcert -file $path 
    rm -r $path 
}  
  
mypath=`pwd`  
filepath=""  
if [ -d .temp_for_certificate ]  
then  
    echo ".temp_for_certificate is exist,remove it first!"  
    exit  
fi  
  
mkdir .temp_for_certificate  
cd .temp_for_certificate  
count=0  
while [ -n "$1" ]    
do    
    if [ `expr substr "$1" 1 1` = "/" ] #绝对路径  
    then  
        filepath="$1"  
    else #相对路径  
        filepath="$mypath/$1"  
    fi  
    if [ -d $filepath ]  
    then  
        all_apk=`find $filepath -name "*.apk"`  
        for apk_path in $all_apk  
        do  
            count=$[$count+1]  
            echo "(#$count) "`basename "$apk_path"`":"  
            filepath=$apk_path  
            get_signature "$filepath"  
            echo "-----------------------------------------------------------"  
        done  
    else  
        count=$[$count+1]  
        echo "(#$count) "`basename "$1"`":"  
        get_signature "$filepath"  
        echo "-----------------------------------------------------------"  
    fi  
    shift  
done    
cd ..  
rm -r .temp_for_certificate  
echo "done!"  

     调用方式:

     sh showInfo.sh <file-name apk>

    e.g.

    sh  showInfo.sh eletricpower.apk

   

(#1) electricpower.apk:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 744df450
Valid from: Sat Apr 18 22:57:14 EDT 2015 until: Mon Apr 10 22:57:14 EDT 2045
Certificate fingerprints:
         MD5:  01:F8:68:23:7D:52:31:E3:56:0D:9E:81:7E:29:18:66
         SHA1: 84:D1:75:85:8E:C7:5B:75:65:87:F8:CB:DF:06:E3:BE:ED:4E:58:B7
         Signature algorithm name: SHA256withRSA
         Version: 3

Extensions: 

#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: EE D2 F9 FB 27 F2 F4 AD   48 F0 64 F9 DC B3 CE 7C  ....'...H.d.....
0010: C2 6A 17 E4                                        .j..
]
]

 2  显示apk信息

      jarsigner -verify -verbose -certs electricpower.apk

查看apk的sha1值以及apk信息

标签:

原文地址:http://blog.csdn.net/john_f_lau/article/details/45149263

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!