Android SDK: how does facebook verify the hash key?

When we want to use the Facebook SDK for Android as our SSO solution, we need to put our Android subscription into our Facebook application settings (step 5 of Facebook sdk for android ).

And this signature should be generated by running keytool, which comes with the Android SDK.

I'm curious how facebook verifies this signature?

+6
source share
2 answers

After more than a year, I think it is better to answer my question.

An Android application may receive a different application signature:

public String WriteSignature(String packageName) { PackageManager pm = this.getPackageManager(); String sig = ""; PackageInfo pi = null; try { pi = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (NameNotFoundException e1) { e1.printStackTrace(); } try { for (Signature signature : pi.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); sig = Base64.encodeToString(md.digest(), Base64.DEFAULT); Log.d(ACTIVITY_TAG, sig); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return sig; } 
+2
source
  • For the facebook application for the function, we need to provide Facebook with the "Application ID"
  • For the Android platform, we need to specify the package name, class name and "HashKey
  • The application will mainly have 2 HashKeys for the Debug and Release versions of the application
  • When the Access application is facebook, the SDK internally generates and compares the HashKey with the one presented during the facebook application.
0
source

All Articles