Current location - Quotes Website - Personality signature - How to get the Android security code SHA 1
How to get the Android security code SHA 1
The first can use the command line.

1. Use the cd command to switch the working directory to the location where the signature is placed.

2. Input: keytool-list-keystordebug.keystore.

3. Enter the password of the keystore: if it is not set, it is blank here, so you can enter it directly.

The second method seems to see the low-profile version of Androidstudio in the settings, but it seems that it can't be seen now. You can also write code to get it and paste it.

Publicstatic string sHA 1 (context context) (

Try {

package info info = context . getpackagemanager()。 getPackageInfo(

context.getPackageName(),PackageManager。 Get _ signature);

byte[] cert = info.signatures[0]。 toByteArray();

message digest MD = message digest . getinstance(" sha 1 ");

Byte[] publicKey = md.digest (certificate);

string buffer hex string = new string buffer();

for(int I = 0; My < public key. Length; i++) {

string append string = integer . tohexstring(0x ff & amp; Public key [i])

. ToUpperCase (regional settings. United States);

if(appendstring . length()= = 1)

hex string . append(" 0 ");

hex string . append(append string);

hex string . append(":");

}

string result = hex string . tostring();

Returns result.substring(0, result.length ()-1);

} catch(NameNotFoundException e){

e . printstacktrace();

} catch(nosuch algorithm exception e){

e . printstacktrace();

}

Returns null

}

This was posted by someone else. I'm too lazy to find the previous code