ANDROID JKS SHA256
How to Get the SHA256 Fingerprint from a JKS Keystore in Android
In Android app development, SHA256 (Secure Hash Algorithm 256-bit) is often required for various authentication and encryption processes. Whether you're working with Google APIs, Firebase, or any service that needs your SHA256 fingerprint, it’s crucial to know how to retrieve this from your JKS (Java KeyStore) file.
This article will guide you through the process of extracting the SHA256 fingerprint from your JKS keystore file using the keytool utility that comes with the Java Development Kit (JDK).
What is SHA256?
SHA256 is a member of the SHA-2 (Secure Hash Algorithm 2) family, producing a 256-bit (64-character) hash value. It is used extensively for ensuring data integrity, encryption, and digital signatures. In Android development, the SHA256 fingerprint is used for services like:
- Google APIs (for example, Google Maps API).
- Firebase Authentication.
- OAuth authentication.
- Ensuring the security and integrity of your app's communications.
Since SHA256 provides a higher level of security than SHA1, some services (like Google Cloud APIs and Firebase) now require you to provide the SHA256 fingerprint of your JKS keystore for authentication purposes.
How to Get SHA256 from a JKS Keystore
Follow these steps to retrieve the SHA256 fingerprint from your JKS keystore:
1. Locate Your JKS Keystore File
Before you can extract the SHA256 fingerprint, you need to know where your JKS file is located. Typically, this file is generated when you create a signed APK for release, and you can locate it through Android Studio or in your project’s directory.
Make sure you know the full path to your keystore file, as you will need it to run the keytool command.
2. Open Terminal/Command Prompt
- On Windows, open Command Prompt.
- On macOS/Linux, open Terminal.
You will use the keytool utility, which comes bundled with the JDK.
3. Run the Keytool Command
Now, use the following keytool command to extract the SHA256 fingerprint from your JKS keystore:
keytool -list -v -keystore /path/to/your/keystore.jks
/path/to/your/keystore.jks: Replace this with the actual path to your JKS keystore file.-list: Tells keytool to list the keystore entries.-v: Outputs verbose details, including the fingerprints.
You will be prompted to enter the keystore password (the one you set when creating the JKS file).
4. Locate the SHA256 Fingerprint
After running the keytool command, you’ll see detailed output that lists information about the keystore, the certificate, and the various fingerprints. Look for the SHA256 fingerprint in the output. It will look something like this:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 1 entry
Alias name: my-key-alias
Creation date: Jun 1, 2025
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Your Name, O=Your Organization, L=Your Location, ST=Your State, C=Your Country
Issuer: CN=Your Name, O=Your Organization, L=Your Location, ST=Your State, C=Your Country
Serial number: 1234567890abcdef
Valid from: Wed Jun 01 12:00:00 UTC 2025 until: Tue Jun 01 12:00:00 UTC 2030
Certificate fingerprints:
SHA1: 3D:22:7B:F7:3D:8D:6F:EE:2B:22:3C:8B:19:7B:F5:DE:15:A1:94
SHA256: 8F:84:4B:F9:B3:21:7A:DC:AF:7A:81:33:FA:3B:32:A0:9E:98:2A:F5
MD5: C4:F7:6F:14:BD:9C:54:B5:9E:20:9D:6C:32:85:7A:74
Signature algorithm name: SHA256withRSA
Version: 3
The SHA256 fingerprint will look something like this:
SHA256: 8F:84:4B:F9:B3:21:7A:DC:AF:7A:81:33:FA:3B:32:A0:9E:98:2A:F5
You can now use this SHA256 fingerprint for Google APIs, Firebase, and other services that require it.
What to Do with Your SHA256 Fingerprint?
Once you have the SHA256 fingerprint of your JKS keystore, you can use it for several purposes:
1. Google APIs (e.g., Google Maps API)
To authenticate and access services like Google Maps, Google Places, and other Google APIs, you’ll need to associate your SHA256 fingerprint with your API key in the Google Cloud Console.
- Go to the Google Cloud Console.
- Navigate to API & Services.
- Find your API Key and select Edit.
- In the API Key Restrictions section, add your SHA256 fingerprint to restrict access to only your app.
2. Firebase Authentication
To use Firebase Authentication (or any other Firebase service), you need to provide the SHA256 fingerprint of your app. Here’s how to add it:
- Go to the Firebase Console.
- Open your Firebase project.
- Under Project Settings, go to the General tab.
- In the Your Apps section, add the SHA256 fingerprint in the App Signing section.
3. OAuth Authentication
If you are using OAuth 2.0 authentication for services like Google Sign-In, the SHA256 fingerprint is required to configure your OAuth client ID in the Google Developer Console.
- Go to the Google Developer Console.
- Open your OAuth 2.0 credentials.
- Add the SHA256 fingerprint under Authorized JavaScript origins or Authorized redirect URIs to complete the authentication process.
Troubleshooting: Common Issues
1. "Keytool" Command Not Found
If you get an error saying "keytool" is not recognized as a command, it means that keytool is not added to your system's PATH.
To resolve this:
- Make sure that Java JDK is installed on your system.
- Add the JDK/bin directory to your system’s PATH.
For example, on macOS/Linux:
export PATH=$PATH:/path/to/jdk/bin
On Windows, you can add the path to keytool.exe (usually in C:\Program Files\Java\jdkX.X.X\bin\) to your PATH environment variable.
2. Incorrect Password
If you’re prompted for a keystore password and enter the wrong one, you’ll not be able to view the certificate details, including the SHA256 fingerprint. Ensure you have the correct password for the JKS keystore.
Conclusion
Getting the SHA256 fingerprint from a JKS keystore is a crucial step when integrating your Android app with various services like Google APIs, Firebase, or OAuth authentication. The process is simple and can be done using the keytool utility from the Java Development Kit (JDK).
Here’s a quick summary of the steps:
- Locate your JKS keystore.
- Run the keytool command with the
-listand-voptions. - Find the SHA256 fingerprint in the output.
- Use the SHA256 fingerprint for Google APIs, Firebase, OAuth, or other services.
By following these steps, you’ll be able to easily extract the SHA256 fingerprint and use it for secure app integrations.

0 Comments