Created
December 2, 2019 06:22
-
-
Save Utshaw/ac0bf1d715a8edd6a530dc9317d022ec to your computer and use it in GitHub Desktop.
Convert SHA-1 key to Base 64 Call this function from MainActivity.java file
This file contains hidden or 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
private void printKeyHash() { | |
try { | |
PackageInfo info = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), | |
PackageManager.GET_SIGNATURES); | |
for(Signature signature: info.signatures){ | |
MessageDigest md = MessageDigest.getInstance("SHA"); | |
md.update(signature.toByteArray()); | |
Log.d("KeyHash", Base64.encodeToString(md.digest(), Base64.DEFAULT)); | |
} | |
} 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