Stack Overflow archive
1 scoreaccepted

How to get Signature hash code of a phone app via adb on pc?

score
1
question views
5K
license
CC BY-SA 3.0

Alex has a great answer.

WARNING: Ugly code ahead

I was able to get the signature in adb shell as root with the following code:

java
package=com.test; b=false; while read line; do case $line in *\<package*${package}*) b=true ;; *\<cert*) if $b; then echo $line | sed -e 's|.*key="||' -e 's|".*||'; b=false; fi esac; done < /data/system/packages.xml

indented:

java
package=com.test
b=false
while read line; do
    case $line in 
        *\<package*${package}*)
            b=true ;; 
        *\<cert*)
            if $b; then
                echo $line | sed -e 's|.*key="||' -e 's|".*||'
                b=false
            fi
    esac
done < /data/system/packages.xml

Originally posted on Stack Overflow. Public user contributions are licensed under Creative Commons Attribution-ShareAlike.