Pages

Thursday 14 March 2013

Android Generate the authentic hash key for Facebook

This is the Code of Generate the Actual Hash key of your Computer.
No Need to  use command prompt ,keytool , keystore.
Just paste this bellow code in your activity and Look at inside you Log.
There is one Log of  "Generated Hash Key".
Just Get it and use it simple...

Here is a quick code snippet :

private void generateHashKey() {
 try {
   PackageInfo info = getPackageManager().getPackageInfo(
     "taranor.taxicustomer.app", PackageManager.GET_SIGNATURES);
   for (Signature signature : info.signatures) {
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(signature.toByteArray());
    Log.d("Generated Hash Key", Base64.encodeBytes(md.digest()));
   }
  } catch (NameNotFoundException e) {
   e.printStackTrace();
  } catch (NoSuchAlgorithmException e) {
   e.printStackTrace();
  }
 }
Only one thing you need is the Base64.java to get this code is working.
I used the Following Link to get Base64.java.

1 comment :