1
votes

keytool -exportcert -alias androiddebugkey -keystore (Your keystore path)\debug.keystore | (Your OpenSSL path)\openssl sha1 -binary | (Your OpenSSL path)\openssl base64)

its not work:error below cmd see error below cmd

how to get key hashes for login with Facebook in app. which java bin path select Program files or Program files(x86).

3

3 Answers

5
votes

Write the -keystore argument in ":

keytool -exportcert -alias androiddebugkey -keystore "C:\Program Files\Java\jdk1.8.0_161\bin\debug.keystore" | c:\openssl-0.9.8e_X64\bin\openssl.exe sha1 -binary | c:\openssl-0.9.8e_X64\bin\openssl.exe base64
0
votes

A filename containing spaces must be quoted on the command line. For example "C:\Program Files\...".

But I also doubt, that your debug keystore is inside the JDK distribution.

-1
votes

Generate KeyHash programatically like this:

 //HashKey Generator
public static String getProjectHashKey(Context context) {
    String hashKey = "";
    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());
            hashKey = Base64.encodeToString(md.digest(), Base64.DEFAULT);
            Log.d("KeyHash:", hashKey);
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    } catch (NoSuchAlgorithmException e) {
        e.printStackTrace();
    }
    return hashKey;
}