How to create Android Facebook Key Hash? How to create Android Facebook Key Hash? android android

How to create Android Facebook Key Hash?


Here is what you need to do -

Download openSSl from CodeExtract it. create a folder- OpenSSL in C:/ and copy the extracted code here.

detect debug.keystore file path. If u didn't find, then do a search in C:/ and use the Path in the command in next step.

detect your keytool.exe path and go to that dir/ in command prompt and run this command in 1 line-

$ keytool -exportcert -alias androiddebugkey -keystore "C:\Documents and Settings\Administrator.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary |"C:\OpenSSL\bin\openssl" base64

it will ask for password, put androidthat's all. u will get a key-hash


For Linux and Mac

Open Terminal :

For Debug Build

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64

You will find debug.keystore in the ".android" folder. Copy it and paste onto the desktop and run the above command.

For release Build

keytool -exportcert -alias <aliasName> -keystore <keystoreFilePath> | openssl sha1 -binary | openssl base64

NOTE : Make sure that in both cases it asks for a password. If it does not ask for a password, it means that something is wrong in the command. Password for debug.keystore is "android" and for release you have to enter password that you set during create keystore.


Please try this:

public static void printHashKey(Context pContext) {        try {            PackageInfo info = pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), PackageManager.GET_SIGNATURES);            for (Signature signature : info.signatures) {                MessageDigest md = MessageDigest.getInstance("SHA");                md.update(signature.toByteArray());                String hashKey = new String(Base64.encode(md.digest(), 0));                Log.i(TAG, "printHashKey() Hash Key: " + hashKey);            }        } catch (NoSuchAlgorithmException e) {            Log.e(TAG, "printHashKey()", e);        } catch (Exception e) {            Log.e(TAG, "printHashKey()", e);        }    }