我无法在Windows上获取登录Facebook的keytool

arknldoa  于 2022-12-05  发布在  Windows
关注(0)|答案(2)|浏览(139)

当我得到登录Facebook的keytool时,我不能得到它。

'keytool' is not recognized as an internal or external command, operable program or batch file.
mf98qq94

mf98qq941#

尝试以下代码以获取Key Hash

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Add code to print out the key hash
    try {
        PackageInfo info = getPackageManager().getPackageInfo(
                "com.facebook.samples.hellofacebook", 
                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 (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }
8cdiaqws

8cdiaqws2#

如果openssl安装在PC上,并且工作目录是JRE的bin文件夹,Abive代码将成功运行。

C:\Program Files\Java\jre<version_number>\bin>

***版本号***取决于安装的 JRE 版本。下载openssl并给予openssl可执行文件的绝对路径。示例代码如下所示

keytool -exportcert -alias <RELEASE_KEY_ALIAS> -keystore <RELEASE_KEY_PATH> | "C:\Users\Anand\Documents\openssl\bin\openssl.exe" sha1 -binary | "C:\Users\Anand\Documents\openssl\bin\openssl.exe" base64

相关问题