Skip to main content

Generate Key Hashes Manually

Key hashes are required for Facebook login to work with your application. Follow the steps below to create your development and release key hashes manually.

Windows#

This section will help you to create development and release key hashes for your application manually using a Command Prompt.

Generating a Development Key Hash#

  1. Download openssl-for-windows openssl library for Windows from the Google Code Archive.

  2. To generate a development key hash, run the following command in a command prompt in the Java SDK folder:

    keytool -exportcert -alias androiddebugkey -keystore "C:\Users\USERNAME\.android\debug.keystore" | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" sha1 -binary | "PATH_TO_OPENSSL_LIBRARY\bin\openssl" base64

    You need to replace the USERNAME from C:\Users\USERNAME\.android\debug.keystore with your user PC name.

    Replace the PATH_TO_OPENSSL_LIBRARY from PATH_TO_OPENSSL_LIBRARY\bin\openssl with the path where you downloaded the openssl-for-windows.

    The password for debug key is android so when prompted for a password enter it.

  3. After successfully completing the step above, a debug key hash will be printed on the terminal.

    Result
    Enter keystore password:
    BGXBgq/KmXXXXXXXXXXXXqOcmvg=

    From your result copy the hashes which look like BGXBgq/KmXXXXXXXXXXXXqOcmvg= this and save for later use. These hashes will be used in the android integration of Facebook Login.

note

You will need to provide a development key hash for the development environment of each person who works on your app.

Generating a Release Key Hash#

Android apps must be digitally signed with a release key before you can upload them to the store. To generate a hash of your release key follow the following steps:

  1. Open a terminal in android studio and paste the following command

    Follow this if you have a tools directory in the root of your project. You will have a tools directory in the root folder of the project if you are using version v1.5.6 or above.

    With Tools Directory
    bash tools/create-release-key-hash.sh

    It will prompt you for a password. The password for your release certificate is the password that you entered in keystore-config.conf file in Editing Keystore Config File - Password.

    Follow this if you do not have a tools directory in the root of your project.

    Without Tools Directory
    keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

    Replace the YOUR_RELEASE_KEY_ALIAS with the alias that you used while creating your keystore.

    Replace the YOUR_RELEASE_KEY_PATH with the full path to your release keystore which you have created.

    After editing your specific values, it should look something like this:

    Example
    keytool -exportcert -alias "my_alias" -keystore "path/to/my/upload.keystore" | openssl sha1 -binary | openssl base64

    The password for this is the same which you used while creating your release keystore.

  2. After successfully completing the step above, a release key hash will be printed on the terminal.

    Result
    Enter keystore password:
    BGXBgq/KmXXXXXXXXXXXXqOcmvg=

    From your result copy the hashes which look like BGXBgq/KmXXXXXXXXXXXXqOcmvg= this and save for later use. These hashes will be used in the android integration of Facebook Login.


Mac OS or Linux#

This section will help you to create development and release key hashes for your application manually using a Terminal.

Generating a Development Key Hash#

  1. To generate a development key hash, open a terminal window and run the following command:

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

    The password for debug key is android so when prompted for a password enter it.

  2. After successfully completing the step above, a debug key hash will be printed on the terminal.

    Result
    Enter keystore password:
    BGXBgq/KmXXXXXXXXXXXXqOcmvg=

    From your result copy the hashes which look like BGXBgq/KmXXXXXXXXXXXXqOcmvg= this and save for later use. These hashes will be used in the android integration of Facebook Login.

note

You will need to provide a development key hash for the development environment of each person who works on your app.

Generating a Release Key Hash#

Android apps must be digitally signed with a release key before you can upload them to the store. To generate a hash of your release key follow the following steps:

  1. Open a terminal in android studio and paste the following command

    Follow this if you have a tools directory in the root of your project. You will have a tools directory in the root folder of the project if you are using version v1.5.6 or above.

    With Tools Directory
    bash tools/create-release-key-hash.sh

    It will prompt you for a password. The password for your release certificate is the password that you entered in keystore-config.conf file in Editing Keystore Config File - Password.

    Follow this if you do not have a tools directory in the root of your project.

    Without Tools Directory
    keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64

    Replace the YOUR_RELEASE_KEY_ALIAS with the alias that you used while creating your keystore.

    Replace the YOUR_RELEASE_KEY_PATH with the full path to your release keystore which you have created.

    After editing your specific values, it should look something like this:

    Example
    keytool -exportcert -alias "my_alias" -keystore "path/to/my/upload.keystore" | openssl sha1 -binary | openssl base64

    The password for this is the same which you used while creating your release keystore.

  2. After successfully completing the step above, a release key hash will be printed on the terminal.

    Result
    Enter keystore password:
    BGXBgq/KmXXXXXXXXXXXXqOcmvg=

    From your result copy the hashes which look like BGXBgq/KmXXXXXXXXXXXXqOcmvg= this and save for later use. These hashes will be used in the android integration of Facebook Login.

You have successfully created the Key Hashes for your debug and release certificates. Now you can continue to follow the guide from where you came here to create key hashes manually.