Android FaceBook登录 分享获取HashKey(密钥散列)的简单方法

代码执行获取密钥散列:
try {
    int i = 0;
    PackageInfo info = getPackageManager().getPackageInfo( getPackageName(),  PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        i++;
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String KeyHash = Base64.encodeToString(md.digest(), Base64.DEFAULT);
        //KeyHash 就是你要的,不用改任何代码  复制粘贴 ;
        Log.e("=========",KeyHash);
    }
}
catch (PackageManager.NameNotFoundException e) {

}
catch (NoSuchAlgorithmException e) {

}

你可能感兴趣的:(Android FaceBook登录 分享获取HashKey(密钥散列)的简单方法)