Table of Contents
How To Generate Google play app signing key hash For Facebook Key Hashes
In this article, we will tell you how to generate Google play app signing key hash, how to generate Facebook key hashes with your laptop or pc. Also how to generate release key hash for facebook in android studio, generate debug key hash, command to generate hash key in android.
convert sha1 to key hash, how sha 1 certificate key hash can be generated in android studio, how to get key hash for facebook login, android app signing key lost, how to get release key hash for facebook android studio. You will find many more in this article. Read the article completely so that you can find the easiest way.
What is key hashes
Key Hashes is a 28 characters of string that is used for Facebook sign in apps. It is used to authenticate the interaction between your app and Facebook. Without this, Facebook does not allow sign in to your app. If you have a Facebook sign in option in your app, then Key Hashes necessary to put it on Facebook’s developer page to authenticate the conversation between one and Facebook.
If you use Facebook sign in your app and your key hashes are not correctly marked on the Facebook developer, then when signing in your app, something goes here like this whose image is given below for the key hashes error You have to provide the correct key hashes on your Facebook developer page.
Required Tools
firstly required same important tools
1.OpenSSl: intall in your pc Download Here
2.Install Java Programm in your Pc Or Laptop Download Now
Simply Run The commond promt
1.Go to your directory
2.cd Program Files
3.select where java programm you have installed then copy all directory without c drive and past the directory in commond promt with cd
4.keytool -exportcert -alias gci -keystore D:\folder name where place your release key |C:\openssl\bin\openssl sha1 -binary |C:\openssl\bin\openssl base64
Output:
Like 28 characters given in below
BW0vlRF2gcmok8unGvozdPyMXko=
Google Play App Signing – KeyHash Mismatch
आप नीचे दिए गए दी गई कमांड को फॉलो करके गूगल प्ले App साइन इन key hashes जनरेट कर सकते हैं.
You have to use the SHA-1 key generated by Google. Following steps would fix it.
1). Go to Google console => Release Management => App signing => App signing certificate.
2). Copy SHA-1 certificate from there and as it's in hexadecimal and since Facebook needs it in base64 so use the command shown in step 3
3).echo SHA-1 key from step-2 (Hexadecimal) | xxd -r -p | openssl base64
This command won't work in command prompt use bash on windows or git cli.
4). Paste the base64 key in Facebook console => Settings => basic => key hashes
You can convert SHA-1 hash in hex format (as found in Play console) into base64 hash using next command (on maybe Git Bash):
echo 05:6D:2F:95:11:76:81:C9:A8:93:CB:A7:1A:FA:33:74:FC:8C:5E:4A | xxd -r -p | openssl base64
Output:
You will get the output of 28 characters which you can put enough by going to Facebook developer and save the page on Facebook download, you will try to sign in with your app, your sign in will show successful.
BW0vlRF2gcmok8unGvozdPyMXko=
This hash can be used for example when setting up Facebook app.
You can extract keyhash from the Sha1 certificate signature. Key hashes are usually extracted in the following way:
public static String getKeyHash(final Context context) {
PackageInfo packageInfo = getPackageInfo(context, PackageManager.GET_SIGNATURES);
if (packageInfo == null)
return null;
for (Signature signature : packageInfo.signatures) {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
return Base64.encodeToString(md.digest(), Base64.NO_WRAP);
} catch (NoSuchAlgorithmException e) {
Log.w(TAG, "Unable to get MessageDigest. signature=" + signature, e);
}
}
return null;
}
You can see that SHA-1 version of signature is Base64 encoded.
Under App Signing menu in Google play developer console, you will see Sha-1 certificate signature that looks like this:
SHA1: 3B:DA:A0:5B:4F:35:71:02:4E:27:22:B9:AC:B2:77:2F:9D:A9:9B:D9
Basically, what you have to do is to change this into a byte array and Base64 encode that byte array. You can do something like:
byte[] sha1 = {
0x3B, (byte)0xDA, (byte)0xA0, 0x5B, 0x4F, 0x35, 0x71, 0x02, 0x4E, 0x27, 0x22, (byte)0xB9, (byte)0xAc, (byte)0xB2, 0x77, 0x2F, (byte)0x9D, (byte)0xA9, (byte)0x9B, (byte)0xD9
};
Log.e("keyhash", Base64.encodeToString(sha1, Base64.NO_WRAP));
You can register this keyhash to facebook android login settings or wherever you like.