How to create a Facebook key hash?

前端 未结 9 1191
独厮守ぢ
独厮守ぢ 2020-12-14 13:15

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

keytool -exportcert -alias androiddebugkey -keystore ~/.andro

9条回答
  •  遥遥无期
    2020-12-14 13:54

    There are two ways to generate Hashkey for Facebook.

    1. You can use the following code snippet

       try {
           PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
           for (Signature signature : info.signatures) {
               MessageDigest messageDigest= MessageDigest.getInstance("SHA");
               messageDigest.update(signature.toByteArray());
               String hashKey = new String(Base64.encode(messageDigest.digest(), 0));
               Log.i("Hash Key ", "value is " + hashKey);
           }
       } catch (NoSuchAlgorithmException e) {
           Log.e("Exception ", "is ", e);
       } catch (Exception e) {
           Log.e("Exception ", "is ", e);
       }
      
    2. You can create Hashkey for Facebook Online by pasting your SHA1 on This link

    Happy Coding :)

提交回复
热议问题