How do I generate my MD5 and SHA1 thumbprints usin

2019-01-23 21:44发布

问题:

Can I generate my MD5 and SHA1 thumbprints using eclipse for my debug keystore? also is there a code for to generate my hash key for facebook as well?

回答1:

get your sha1 and md5 thumbprint for debug keystore (also works for your other keystores). Go to you package exporler in eclipse (defaults to the left side) right click it>android tools>export signed application package

Then navigate to your debug keystore normally in your .android folder and select it

Then enter the password which is "android" with no quotes

Next it will ask for an alias click the drop down list and select androiddebugkey and again, enter android as the password.

Next if you scroll down it will show the MD5 and SHA1 thumb print if you scroll down

then just cancel and use it how you want if you want your hash key just paste this under your onCreate

REPLACE "com.you.name" to your application package name.

PackageInfo info;
try {

    info = getPackageManager().getPackageInfo( "com.you.name",PackageManager.GET_SIGNATURES);

    for (Signature signature : info.signatures)
    {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String something = new String(Base64.encode(md.digest(), 0));
        //String something = new String(Base64.encodeBytes(md.digest()));
        Log.e("Hash key", something);
    }

} catch (NameNotFoundException e1) {
Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
Log.e("exception", e.toString());
}


回答2:

In eclipse go to ----Window->Preferences->Android->Build----- and then you will find your MD5 and SHA1 key of your debug keystore. This is so much easier than using the annoying command prompt.



回答3:

// Google Map SHA1   
keytool -list -v -keystore yourkeystore //run this command on terminal after it ask keystore password if not then some problem and debug keystore you to find debug keystore directory path and run above command it password is android 

// Facebook HashKey
keytool -exportcert -alias keystorealias -keystore keystore | openssl sha1 -binary | openssl base64 //run this command on terminal