I\'m working on an Android app, in which I want to integrate a Facebook posting feature. I downloaded the Facebook-Android SDK, and I got the readme.md (text file) in there,
Kotlin code to get Hash key
private fun logHashKey() {
try {
val info = getPackageManager().getPackageInfo("your.package.name", PackageManager.GET_SIGNING_CERTIFICATES);
for (signature in info.signingInfo.signingCertificateHistory) {
val md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
val something = Base64.getEncoder().encodeToString(md.digest());
Log.e("hash key", something);
}
} catch (e1: PackageManager.NameNotFoundException) {
Log.e("name not found", e1.toString());
} catch (e: NoSuchAlgorithmException) {
Log.e("no such an algorithm", e.toString());
} catch (e: Exception) {
Log.e("exception", e.toString());
}
}
Please don't forgot to generate keys in Debug and Release environment as they change as per build setting.