Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Last active March 8, 2019 05:37
Show Gist options
  • Save EmmanuelGuther/73a13a0d7a1da2931832ea75c5c3d9aa to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/73a13a0d7a1da2931832ea75c5c3d9aa to your computer and use it in GitHub Desktop.
private fun printKeyHash() {
try {
val info = activity?.packageManager?.getPackageInfo("com.s", PackageManager.GET_SIGNATURES)
for (signature in info!!.signatures!!) {
val md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT))
}
} catch (e: PackageManager.NameNotFoundException) {
Log.e("KeyHash:", e.toString())
} catch (e: NoSuchAlgorithmException) {
Log.e("KeyHash:", e.toString())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment