Search code examples
androidapihashkeytoolone-time-password

Generating hash string for google sms retriever api - 'xxd' is not recognized as an internal or external command


After the google's new policy regarding SMS and Call log permissions, I am trying to implement SMS retriever API for my android application. The tutorial seems easy but I found a problem while creating/generating hash for the same.

When I type

keytool -alias MyAndroidKey -exportcert -keystore MyProduction.keystore | xxd -p | tr -d "[:space:]"

OR

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

It says:

'xxd' is not recognized as an internal or external command,
operable program or batch file.

'tr' is not recognized as an internal or external command,
operable program or batch file.

There are no clarification available on https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string page

Thanks.


Solution

  • Finally I managed to get hash key for using SMS retriever API - Android.

    Steps I followed.

    1. I was using Git so it was installed on my machine. Head over to C:\Program Files\Git\usr\bin and I see that it has xxd.exe and tr.exe which was my requirement.

    2. So I added the environment variable to Path > New > C:\Program Files\Git\usr\bin

    3. Restart the cmd with administrator privileges. xxd and tr command started working.

    Hope this will help others as google has stopped CALL_LOG, READ_SMS permission.

    Cheers.

    ---------------------UPDATE-----------------------

    I found an another good answer here.

    Please follow the link it gives a step by step tut for creating the hash key.

    I followed this because after publishing app to play store the generated hash key doesn't work any more.

    How to generate 11 char hash key for Sms Retriever with Google App signing

    Hope it will help someone!