Facebook秘钥散列获取(正式包)

新建安装java项目,MainActivity里面替换下面代码,运行搜索KeyHash: 即使正式Facebook秘钥散列


import androidx.appcompat.app.AppCompatActivity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.Signature;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        facebookHashKey();
    }
    
    //Facebook秘钥散列获取
    private void facebookHashKey() {
        try {
            PackageInfo info = getPackageManager().getPackageInfo("com.hnqxtech.funwalk", 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));
            }
        } catch (PackageManager.NameNotFoundException e) {
        } catch (NoSuchAlgorithmException e) {
        }
    }

}

你可能感兴趣的:(Facebook秘钥散列获取(正式包))