facebook hash key

    private void printHashKey() {
        try {
            PackageInfo info = getPackageManager().getPackageInfo(
                    "xxx.xx.xxx.x",
                    PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String base64Key = Base64.encodeToString(md.digest(), Base64.DEFAULT);
                Log.i("hashKey", base64Key);
            }
        } catch (PackageManager.NameNotFoundException e) {

        } catch (NoSuchAlgorithmException e) {

        }
    }

也可以用命令行:

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | openssl sha1 -binary | openssl base64
posted @ 2016-04-20 16:24  观海云不远  阅读(312)  评论(0编辑  收藏  举报