问题描述
我选择了谷歌播放应用程序签名,我知道谷歌改变了应用程序的签名密钥,我发现了沙1证书,但无法找到keyhash。
如何获得我发布的应用程序的keyhash是否有方法从证书中提取它? 解决方案
我选择了谷歌播放应用程序签名,我知道谷歌改变了应用程序的签名密钥,我发现了沙1证书,但无法找到keyhash。
如何获得我发布的应用程序的keyhash是否有方法从证书中提取它? 解决方案
您可以从Sha1证书签名中提取keyhash 。密钥散列通常以下列方式提取:
public static String getKeyHash(final Context context){
PackageInfo packageInfo = getPackageInfo(context,PackageManager.GET_SIGNATURES);
if(packageInfo == null)
return null;
(签名签名:packageInfo.signatures){
尝试{
MessageDigest md = MessageDigest.getInstance(SHA);
md.update(signature.toByteArray());
返回Base64.encodeToString(md.digest(),Base64.NO_WRAP);
} catch(NoSuchAlgorithmException e){
Log.w(TAG,Unable to get MessageDigest。signature =+ signature,e);
}
}
返回null;
$ / code>
您可以看到SHA-1版本的签名是Base64编码的。
在Google Play开发者控制台中的应用签名菜单下,您将看到Sha-1证书签名,如下所示:
SHA1:3B:DA:A0:5B:4F:35:71:02:4E:27:22:B9:AC:B2:77:2F:9D:A9: 9B:D9
基本上,你所要做的就是把它变成一个字节数组和Base64编码那个字节数组。你可以这样做:
byte [] sha1 = {
0x3B,(byte)0xDA,(byte) (字节)0xA0,(字节)0xB2,0x77,0x2c,(字节)0x9D,(字节)0xA9,(字节)0xA0,0x4F,0x35,0x71,0x02,0x4e,0x27,0x22, 0x9B,(byte)0xD9
};
Log.e(keyhash,Base64.encodeToString(sha1,Base64.NO_WRAP));
您可以将此keyhash注册到facebook android登录设置或任何您喜欢的位置。
I have opted for google play app signing and i understand that google changes the signing keys for the app and I found the Sha 1 certificate but couldnt find the keyhash .
How can i get the keyhash of my released app is there a way to extract it from the certificate?
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.
这篇关于Google Play应用签名密钥哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!