Skip to content

Instantly share code, notes, and snippets.

@jd-alexander
Created April 30, 2018 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jd-alexander/0e45a25c4ddc194a3700f0af78254348 to your computer and use it in GitHub Desktop.
Save jd-alexander/0e45a25c4ddc194a3700f0af78254348 to your computer and use it in GitHub Desktop.
val TAG = "hash"
try {
val info = context.packageManager.getPackageInfo("", PackageManager.GET_SIGNATURES)
for (signature in info.signatures) {
val md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
val hashKey = String(Base64.encode(md.digest(), 0))
Log.i(TAG, "printHashKey() Hash Key: $hashKey")
}
} catch (e: NoSuchAlgorithmException) {
Log.e(TAG, "printHashKey()", e)
} catch (e: Exception) {
Log.e(TAG, "printHashKey()", e)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment