Zheng Li Zheng Li - 1 year ago 105
Android Question

Is there any way to get key hash from signed APK?

Is there any way to get key hash from signed APK?
We have a signed Android apk file, and we want to find out key hash of this APK, for Facebook SDK.
Can we do that by something like jarsigner?
Any suggestions?

Answer Source

For windows users getting the key from openssl, may be tricky some times.. I always use this to find the right signature.. Just paste this code in your onCreate() and run.

 // Add code to print out the key hash
  try {
  PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
  for (Signature signature : info.signatures) {
  MessageDigest md = MessageDigest.getInstance("SHA");
  Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
  } catch (NameNotFoundException e) {

  } catch (NoSuchAlgorithmException e) {



Using Android studio(2.1.2):

  1. Click on the gradle icon.
  2. Choose your app -> Tasks -> SigningReport

This will run a gradle task that will print the debug and release certificate with md5 and sha1 keys

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download