How to get Hash Key for android application

To get Hash Key copy below code in onCreate() of your Activity class. Run and check Logcat for result

try {
               PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
               for (Signature signature : info.signatures)
                MessageDigest md = MessageDigest.getInstance("SHA");
                System.out.println("KeyHash:  "+Base64.encodeToString(md.digest(), Base64.DEFAULT));
              } catch (NameNotFoundException e) {
               Log.e("error NameNotFoundException: ", e.toString());
              } catch (NoSuchAlgorithmException e) {
               Log.e("error NoSuchAlgorithmException: ", e.toString());

Leave a Reply

Your email address will not be published. Required fields are marked *

Get Widget