SHA 1 or SHA-256 and Key Hash
  • Overview
  • How to download JDK
  • Find SHA-1 & SHA-256
    • Setup pre-processing
    • Find debug SHA-1 & SHA-256
    • Find release SHA-1 & SHA-256
  • Find Hash Key
    • Setup Pre-processing
    • Find Debug Hash key
    • Find Debug Hash key using Code
    • Find Release Hash Key
Powered by GitBook
On this page
  1. Find Hash Key

Find Debug Hash key using Code

If you get a debug hash key from using Code in Android, you must try this code.

try {
	PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
	for (Signature signature : info.signatures) {
		MessageDigest md = MessageDigest.getInstance("SHA");
		md.update(signature.toByteArray());
		Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
	}
} catch (NameNotFoundException e) {
	Log.e("KEY HASH ERROR:", "NameNotFoundException: " + e.getMessage());
} catch (NoSuchAlgorithmException e) {
	Log.e("KEY HASH ERROR:", "NoSuchAlgorithmException: " + e.getMessage());
}

Put this code into MainActivity.java into onCreate() function and run the app, you will find key in logcat

PreviousFind Debug Hash keyNextFind Release Hash Key

Last updated 1 year ago