How to generate 11 char hash key for Sms Retriever with Google App signing
Here is the complete step by step guide .
- Go to play console -> open app -> Release management -> App Signing -> Download Certificate . Like in below screen shot
This will give you deployment_cert.der
file
- Convert the
deployment_cert.der
file to a.jks
file
use below command
keytool -importcert -alias YOUR_ALIAS -file deployment_cert.der -keystore certificate.jks -storepass YOUR_PASSWORD
Replace YOUR_ALIAS,YOUR_PASSWORD with yours which used in keystore . In place of deployment_cert.der
use complete path if required
After entering this command it will ask
Trust this certificate? [no]: yes
type yes and click enter . It will show message
Certificate was added to keystore
This will generate a new file certificate.jks
Now in terminal enter command
keytool -exportcert -alias YOUR_ALIAS -keystore certificate.jks | xxd -p | tr -d "[:space:]" | echo -n YOUR_PACKAGE `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
Replace YOUR_ALIAS,YOUR_PACKAGE with yours which used in keystore,project . In place of certificate.jks
use complete path if required
it will ask for password
Enter keystore password: mypassword
enter your password and you will get the hash .
EDIT For MacOS users:
If you're using MacOS you can install sha256sum by installing coreutils like this:
brew install coreutils
Or you can use shasum -a 256
instead of sha256sum
like this:
keytool -exportcert -alias YOUR_ALIAS -keystore certificate.jks | xxd -p | tr -d "[:space:]" | echo -n YOUR_PACKAGE `cat` | shasum -a 256 | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
Credits to Abhinav Gupta and Op of this question Farhan Farooqui and above answer from Nick Fortescue
Generated 11 char hash code is not working after google app signing is enabled
When Google's App Signing enable 11 char hash will be generated without alias
i.e SMS Retrieve API
The following command computes the hash string from your app's
production keystore:
keytool -exportcert -alias MyAndroidKey -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
in the above command hash is generating based on MyAndroidKey alias (-alias MyAndroidKey
).
Try generating hash without alias for Google APK Sign Enabled
i.e
keytool -exportcert -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11
Related Topics
Place Imageview Over Button Android
How to Use the Gradle Build System for Android with Eclipse
Android Bluetoothdevice.Getname() Return Null
Android Saf (Storage Access Framework): Get Particular File Uri from Treeuri
Android: Programmatically Adding Buttons to a Layout
Camera Intent Not Working with Samsung Galaxy S3
Scan Android Sd Card for New Files
Android Studio: Gradle: Error: Cannot Find Symbol Variable
How to Change the Style of a Datepicker in Android
Android: Capturing the Return of an Activity
How to Control the Scrolling Speed of Recyclerview.Smoothscrolltoposition(Position)
Startlescan with 128 Bit Uuids Doesn't Work on Native Android Ble Implementation