Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pipiscrew/0d664d5ef8125534a75b to your computer and use it in GitHub Desktop.
Save pipiscrew/0d664d5ef8125534a75b to your computer and use it in GitHub Desktop.
[android] get sign hash for facebook
//verified is the same as OpenSSL
public void btnSIGN_Click(View v) {
try {
packageInfo = getPackageManager().getPackageInfo("com.example.test2.test2.fb", PackageManager.GET_SIGNATURES);
for (Signature signature : packageInfo.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String key = new String(Base64.encode(md.digest(), 0));
Toast.makeText(MainActivity.this, key + "\r\nsee LogCat", Toast.LENGTH_LONG).show();
Log.d("KeyHash:", key);
}
} catch (NameNotFoundException e1) {
Log.e("Name not found", e1.toString());
}
catch (NoSuchAlgorithmException e) {
Log.e("No such an algorithm", e.toString());
} catch (Exception e) {
Log.e("Exception", e.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment