Friday, 16 August 2013

Find SHA key programmatically


try {
    PackageInfo info = getPackageManager().getPackageInfo(
          "com.facebook.login", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) 
        {
           MessageDigest md = MessageDigest.getInstance("SHA");
           md.update(signature.toByteArray());
           Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
    }
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}

No comments:

Post a Comment