SHA-1 fingerprint of keystore certificate

前端 未结 30 3009
长发绾君心
长发绾君心 2020-11-21 23:36

Is the method for getting a SHA-1 fingerprint the same as the method of getting the a fingerprint? Previously, I was running this command:

相关标签:
30条回答
  • 2020-11-22 00:05

    First there is same .jar file that in fb-sdk android-support-v4.jar.
    Then generate SHA1 key using:

    PackageInfo info;
    try {
    
        info = getPackageManager().getPackageInfo(
            "com.example.worldmission", 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));
            Log.e("Hash key", something);
            System.out.println("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());
    }
    
    0 讨论(0)
  • 2020-11-22 00:05

    In Addition to Lokesh Tiwar's answer

    For release builds add the following in the gradle:

    android {
    
    defaultConfig{
    //Goes here
    }
    
        signingConfigs {
            release {
                storeFile file("PATH TO THE KEY_STORE FILE")
                storePassword "PASSWORD"
                keyAlias "ALIAS_NAME"
                keyPassword "KEY_PASSWORD"
            }
        }
    buildTypes {
            release {
                zipAlignEnabled true
                minifyEnabled false
                signingConfig signingConfigs.release
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    
    }
    

    Now running the signingReport as in Lokesh's Answer would show the SHA 1 and MD5 keys for the release builds as well.

    0 讨论(0)
  • 2020-11-22 00:06

    from a Debug Keystore we can get the SHA1 value in Eclipse. Accessing from the menu: Window -> Preferences -> Android -> Build

    but it doesn´t work for a production Keystore. enter image description here

    So, to get the SHA1 value from a production Keystore go to: Android Tools -> Export Signed Application Package. Follow the process for signing your apk and the SHA1 will showed as a certificate.

    enter image description here

    0 讨论(0)
  • 2020-11-22 00:07

    if you have not the Keystore and alias you can use this command :

    keytool -list -printcert -jarfile app.apk
    
    0 讨论(0)
  • 2020-11-22 00:08

    Go to your java bin directory via the cmd:

    C:\Program Files\Java\jdk1.7.0_25\bin>

    Now type in the below comand in your cmd:

    keytool -list -v -keystore "c:\users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android 
    
    0 讨论(0)
  • 2020-11-22 00:08

    If you are using Android Studio IDE then you can get SHA1 has value for your all build variants with one click.

    Under Gradle Projects Window > Select Root Project > signingReport > double click

    Next

    Go To Variant: release for release

    Go To Variant: debug for debug

    http://devdeeds.com/create-sha1-key-using-android-studio/

    0 讨论(0)
提交回复
热议问题