如何创建一个Facebook密钥散列? [英] How to create a Facebook key hash?

查看:4590
本文介绍了如何创建一个Facebook密钥散列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Facebook的Andr​​oid的教程中,我们被告知要使用下面的code创建一个关键的哈希值:

In the Facebook android tutorial we are told to use following code to create a key hash:

密钥工具-exportcert -alias androiddebugkey -keystore〜/ .android / debug.keystore | OpenSSL的SHA1 -binary | OpenSSL的BASE64

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64

这是确切的code在所有情况下使用?例如,而不是〜/ .android / debug.keystore 要它像 C:/folderone/foldertwo/.android/debug.keystore

Is this the exact code to use in all situations? For example instead of ~/.android/debug.keystore should it something like C:/folderone/foldertwo/.android/debug.keystore?

正如你所看到的,我不确定引号是否需要与否,全路径是否需要与否!

As you can see I'm unsure of whether inverted commas are required or not, whether full paths are required or not!

有没有人能够提供一个真实世界的例子?

Is anyone able to provide a real world example?

请参阅
https://developers.facebook.com/docs/mobile/android/build/ #sso

推荐答案

尝试

try {
PackageInfo info = getPackageManager().getPackageInfo("com.eatapp", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(signature.toByteArray());
    Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

在您的主要活动:-)这是它为我的作品为Android SDK 3.0

in your main Activity :-) This is the only solution it works for me for Android SDK 3.0

这篇关于如何创建一个Facebook密钥散列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆