Facebook Android Generate Key Hash

后端 未结 21 2038
误落风尘
误落风尘 2020-11-22 04:11

Trying to create an android app with Facebook integration, I\'ve gotten to the part in the docs where you have to generate a key hash file, it specifies to run the following

21条回答
  •  盖世英雄少女心
    2020-11-22 04:50

    Generate Debug hash key

      public String hashkey(Context context) {
            String keyhash = "";
            try {
                PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
                for (Signature signature : info.signatures) {
                    MessageDigest md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                    keyhash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
                }
            } catch (PackageManager.NameNotFoundException e) {
    
            } catch (NoSuchAlgorithmException e) {
    
            }
            return keyhash;
        }
    

    Generate Release hash key

     keytool -exportcert -alias specialbridge -keystore /home/shilpi/newproject/specialBridge/SpecialBridgeAndroid/keystore/specialbridge.jks | openssl sha1 -binary | openssl base64
    

提交回复
热议问题