30

I use some command to get MD5 private key from debug.keystore file but actually I get SHA1 private key instead of MD5. I do not know how to get MD5.

This is command that I use.

keytool -list -alias androiddebugkey -keystore (path_to_debug_keystore).keystore -storepass android -keypass android
Slim
  • 1,708
  • 5
  • 37
  • 60
Mojiiz
  • 7,898
  • 6
  • 26
  • 25
  • 5
    It seems the v1.7 JDK is showing SHA1 by default instead of MD5 (I don't remember having this problem on my old PC). – whitey04 Oct 02 '11 at 00:22
  • possible duplicate of [How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?](http://stackoverflow.com/questions/12214467/how-to-obtain-signing-certificate-fingerprint-sha1-for-oauth-2-0-on-android) – Randy Sugianto 'Yuku' Jul 27 '15 at 09:26

11 Answers11

43

Try to simply add a -v to your command. Then you will get fingerprints in MD5, SHA1 and SHA256. The MD5 one should be accepted by Google API Signup. =)

rafaelrezend
  • 935
  • 1
  • 11
  • 25
31

When I did it I used this.

keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android -v

Looks like your keystore file isn't correct.

Robby Pond
  • 73,164
  • 16
  • 126
  • 119
  • 9
    please add the -v option for future reference. This answer isn't correct, as it only replicates what the OP tried. Also, his file wasn't incorrect, because debug.keystore has more than one fingerprint. I really don't understand why this is the "correct" answer. – Guilherme David da Costa Nov 20 '12 at 03:49
  • 2
    This answer is obsolete, the "-v" option [no more prints MD5](https://bugs.openjdk.java.net/browse/JDK-8249541) for JDK 8 and newer. – Alexander Farber Apr 27 '21 at 15:54
22

You do not need to downgrade your jdk!

You should add '-v' to your keytool command, as already suggested.

keytool -list -v -keystore ~/.android/debug.keystore

This is because you are using jdk7 which, unlike jdk6, does not print the MD5 certificate fingerprint by default.

The android documentation does not mention this (as per postdate)

user1202032
  • 1,430
  • 3
  • 15
  • 36
  • but mine is turning into Runtime Exceptions. – Jeff Bootsholz Oct 06 '12 at 03:25
  • This answer worked, but prompted me for a password. The password (as noted in other answers) is "android" – k2col Oct 22 '17 at 02:21
  • My command is : keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepas s android -keypass android , but it is not returning MD5, but only SHA1 and SHA256. – Abhinav Saxena Sep 26 '18 at 07:32
5

Thanks everyone. Now i got my MD5 private key. I used JDK7. For your reference,

C:\Program Files\Java\jdk1.7.0\bin>keytool.exe -list -v -keystore "C:\Documents
and Settings\Administrator\.android\debug.keystore" -storepass android -keypass
android
Echilon
  • 10,064
  • 33
  • 131
  • 217
Praveen
  • 51
  • 1
  • 1
3

you have the right sintaxis, be sure where is your keystore file located...

this is my example:

keytool -list -alias androiddebugkey -keystore "C:\Documents and Settings\jorgesys\.android\debug.keystore" -storepass android -keypass android

and the result must be something like...

androiddebugkey, 25/09/2010, PrivateKeyEntry,
Certificate fingerprint (MD5):
32:46:AA:56:D9:71:8B:2A:0B:34:A1:B6:96:1E:87:59

if you don't remember your user and password you will create another keystore...

keytool -genkey -v -keystore "C:\android\gruporeforma.keystore" -alias gruporeforma -keyalg RSA -validity 10000
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 1
    This is my command ---> (keytool -list -alias androiddebugkey -keystore C:\Users\user\.android\debug.keystore -storepass android -keypass android) but I still get SHA1 private key – Mojiiz Mar 10 '11 at 18:05
  • 1
    This is still not giving MD5 in the results, I am only getting SHA1 and SHA256. – Abhinav Saxena Sep 26 '18 at 07:29
2

This will help you definately. Please refer this screen shot.....

enter image description here

Mitul Goti
  • 2,657
  • 1
  • 22
  • 19
2

If you are using Eclipse or ADT you can go to Preferences -> Android -> Build and there you will see your debug keystore MD5 and SHA1 fingerprints.

user1252459
  • 563
  • 7
  • 7
2

Make sure your are currently in jdk/bin in your terminal

For Linux or OS X, open a terminal window and enter the following:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

For Windows Vista and Windows 7, run:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

If you are successful in above step you will get:

Alias name: androiddebugkey
Creation date: Jan 01, 2013
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4aa9b300
Valid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033
Certificate fingerprints:
     MD5:  AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9
     SHA1: BB:0D:AC:74:D3:21:E1:43:07:71:9B:62:90:AF:A1:66:6E:44:5D:75
     Signature algorithm name: SHA1withRSA
     Version: 3
Enzokie
  • 7,365
  • 6
  • 33
  • 39
  • In my case the output is not giving MD5: – Abhinav Saxena Sep 26 '18 at 07:14
  • Valid from: Mon Apr 30 12:59:46 IST 2018 until: Wed Apr 22 12:59:46 IST 2048 Certificate fingerprints: SHA1: 75:B9:88:AF:D3:E3:_:1B:40:B1:61:0D:4A:FF:35:B9:_:CD:7B:28 SHA256: C4:87:91:E1:DD:E5:B2:_:57:D0:DE:C7:1D:6D:E2:87:94:_:4A:20:EB:AB:99:73:74:B7:12:EB:04:AD:9E:5A Signature algorithm name: SHA1withRSA – Abhinav Saxena Sep 26 '18 at 07:16
  • 2
    @AbhinavSaxena do you have Android Studio installed right now? If yes open your project; at the right side click `Gradle > Your project > Tasks > Android > signingReport` and it will show similar thing above. – Enzokie Sep 26 '18 at 07:25
  • Yes it is working there. But what is the command it must be issuing there? – Abhinav Saxena Sep 26 '18 at 07:38
  • @AbhinavSaxena I can't answer that sorry. – Enzokie Sep 26 '18 at 07:39
  • In the output using my command line, it is showing version as 1 in the last line. In yours it is 'version: 3'. – Abhinav Saxena Sep 26 '18 at 07:41
  • I don't know how to produce the version code but if I remember correctly I am using OpenJDK. – Enzokie Sep 26 '18 at 07:46
  • It is not working: on my console, where the version is --> java version "10.0.2" 2018-07-17 Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13) Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode) – Abhinav Saxena Sep 26 '18 at 09:09
1

I had the same problem use java jdk6 not jdk7 ... work for me

Kemal Fadillah
  • 9,760
  • 3
  • 45
  • 63
0

Thanks for everyone. I can generate my MD5 private key. I know the some problem. If I use java version 7, I will get SHA1 but when I downgrade java version such as jdk1.6, I will also get MD5.

Mojiiz
  • 7,898
  • 6
  • 26
  • 25
0

I saw that answer in the link:

How to get 'MD5' instance from keystore instead of 'SHA' ?

Reason being, in the other answers, the command line is used to get the SHA, MD5, but a program can elaborate to explicitly get the MD5 instance from a signature. In the above case, you are specifying SHA, hence you will get SHA only.

Happy Coding :-)

Abhinav Saxena
  • 1,990
  • 2
  • 24
  • 55