Skip to content

Instantly share code, notes, and snippets.

@thedoapps
Last active March 24, 2016 02:26
Show Gist options
  • Save thedoapps/6dd1bbe22e1f6cd3a2f0 to your computer and use it in GitHub Desktop.
Save thedoapps/6dd1bbe22e1f6cd3a2f0 to your computer and use it in GitHub Desktop.
This code is used to generate the key fragments in android using facebook.
try {
PackageInfo info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String something = new String(Base64.encode(md.digest(), 0));
//this is key has of facebook
Log.e("fb_hash", something);
}
}
catch (PackageManager.NameNotFoundException e1) {
// TODO Auto-generated catch block
Log.e("name not found", e1.toString());
}
catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
Log.e("no such an algorithm", e.toString());
}
catch (Exception e){
Log.e("exception", e.toString());
}
Log.e("DATA", "ya viene fb");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment