Created
May 29, 2014 09:03
-
-
Save pipiscrew/0d664d5ef8125534a75b to your computer and use it in GitHub Desktop.
[android] get sign hash for facebook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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