Issue
I am using twilio sdk to integrate sms verification with my android app, twilio asks me to register hash signature of my app and non of ways to generate hash signature worked, always says it is invalid hash signature this is the path that twilio wants the hash signature
Solution
User below command in terminal of android studio to generate release key hash
keytool -exportcert -alias [aliasname] -keystore [your app keystore path] | openssl sha1 -binary | openssl base64
And below code in your project to get development key hash
try {
android.content.pm.PackageInfo info = getPackageManager().getPackageInfo(
"com.apps.sonictonic",
android.content.pm.PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
android.util.Log.d("KeyHash", "KeyHash:" + android.util.Base64.encodeToString(md.digest(),
android.util.Base64.DEFAULT));
}
} catch (android.content.pm.PackageManager.NameNotFoundException e) {
} catch (java.security.NoSuchAlgorithmException e) {
}
Answered By - Zealous System
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)