Created
July 13, 2017 14:38
-
-
Save isfaaghyth/f8c73ac9da82afeb0d8bb7e87002bd98 to your computer and use it in GitHub Desktop.
This file contains 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
public class KeyHash { | |
public static void generateKeyHash(Context context) { | |
try { | |
PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); | |
for (Signature signature : info.signatures) { | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
String something = new String(Base64.encode(md.digest(), 0)); | |
Log.e("Hash key", something); | |
} | |
} catch (PackageManager.NameNotFoundException e) { | |
e.printStackTrace(); | |
} catch (NoSuchAlgorithmException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment