How can I get the MD5 fingerprint from Java's keytool, not only SHA-1?

81,697

Solution 1

With JDK 1.7 installed, keytool always outputs by default SHA1 fingerprint, not MD5. you can get the MD5 Certificate by adding -v option.

use the following code:-

C:\Program Files\Java\jdk1.7.0\bin>keytool -v -list -alias
androiddebugkey -keystore debug.keystore -storepass android -keypass android

it will output MD5 certificate as well.

Solution 2

To get MD5 value and SHA1...etc fallow this below:

Before this dont forget to copy the debug.keystore to a folder Androidkeystore like that created in C drive.

C:\Program Files\Java\jdk1.7.0_05\bin>keytool -v -list -keystore C:\Androidkeyst
ore\debug.keystore

it asks here.. Enter keystore password: android

enter you got here MD5 & SHA1..etc

Keystore type: JKS
Keystore provider: SUN

Your keystore contains ? entry

Alias name: androiddebugkey
Creation date: ?? ???, ????
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[?]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 67b6344b
Valid from: Mon Jun 18 20:33:56 IST 2012 until: Wed Jun 11 20:33:56 IST 2042
Certificate fingerprints:
         MD5:  C2:61:51:3E:BC:C8:0C:DB:75:B6:E7:C4:90:AD:91:39
         SHA1: CD:5E:8A:0F:4E:0F:2E:FD:92:5E:5E:4R:CF:F8:44:33:2C:8C:B8:97
         SHA256: B5:BF:75:60:DB:62:09:49:F1:38:CH:49:18:22:18:95:03:C9:5C:14:F6:
B0:F4:21:D2:19:B8:FF:38:D2:B9:FD
         Signature algorithm name: SHA256withRSA

NOTE: if there are any spaces in the directory path you MUST enclose it in quotes. e.g. use this format:

-keystore "C:\Users\Your Name\.android\debug.keystore"

Solution 3

If you are using jdk 7:

Use -v option.

Solution 4

Hello in the year 2021.

The keytool of JDK 8 and newer does not print MD5 anymore, even if you try the standard suggestion to add the "-v" option to the "keygen -list" command.

I guess MD5 is no more considered secure enough and has been removed.

At the same time there are still places like Amazon "Security Profile Management" for LWA etc. requiring you to submit the MD5 signature of your certificate.

Here is a command which will deliver it (use the password "android" for the Android Studio keystore):

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | \
openssl dgst -md5 

And if you want to have colon character inbetween, then add the following "sed" command:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | \
openssl dgst -md5 | \
sed 's/[a-fA-F0-9][a-fA-F0-9]/&:/g; s/:$//'

The above command works on Linux, macOS and even Windows (in git bash):

MinGW screenshot

Solution 5

The easiest way to get SHA 1,MD 5 is to click on Gradle in the upper hand right side near the corner of the screen of Android Studio. Then click on the name of the app(e.g android123(root): it should appear like this). After that, you will find a subfolder named android and clicking on it go for the signingReport.It should run in the console and should show you the SHA 1,MD 5. Hope it helps.

Share:
81,697

Related videos on Youtube

Prachi Kshirsagar
Author by

Prachi Kshirsagar

Updated on April 30, 2021

Comments

  • Prachi Kshirsagar
    Prachi Kshirsagar about 3 years

    As I want to use Google maps in my application, I need the debug certificates' MD5 fingerprint. I tried following.:

    (Here I copied the debug.keystore file from C:\Documents and Settings\Administrator.android in bin folder)

    C:\Program Files\Java\jdk1.7.0\bin>keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android
    

    But got the following results:

    androiddebugkey, May 27, 2011, PrivateKeyEntry,Certificate fingerprint (SHA1): "some code"
    

    However that is not working to get MAP API key. Is SHA1 is same as MD5?

    What should I do to get the MD5 certificate?

  • Joseph Earl
    Joseph Earl over 12 years
    Thanks, the -v option did it for me
  • Riking
    Riking about 12 years
    Please note the date that this question was asked. Don't answer old questions unless you think that you have a better answer.
  • fjs
    fjs about 12 years
    I just did it because it solve my problem. And I just got the problem now. I just wanted to left something if anyone comes with the same problem now. By the way thanks for the minus 2 points. :(
  • Onimusha
    Onimusha about 11 years
    @AnkitSaxena This answer is better and helped me so please do not stop anyone from providing an alternative answer with different information. Thanks K.krishnan for this answer +1
  • Crishnan Kandada
    Crishnan Kandada almost 11 years
    Now MD5 & sha1 process changed Google After we got MD5 here.we need to get API key from Google API console right. thanks guys
  • v1h5
    v1h5 almost 5 years
    @Ankit-Saxena - Can you please answer this stackoverflow.com/questions/55336382/… -v option is not working with me.
  • Yuri Reis
    Yuri Reis about 4 years
    Thank you! All the other answers didn't work for me, but this one did.
  • dragon788
    dragon788 over 3 years
    This could be simplified as running ./gradle signingReport.
  • Alexander Farber
    Alexander Farber about 3 years
    This answer is obsolete, the "-v" option no more prints MD5 for JDK 8 and newer.