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

3

14

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.

Freshen answered 16/1, 2019 at 6:31 Comment(0)
F
16

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!

Freshen answered 16/1, 2019 at 11:6 Comment(4)
when i try to generate my hash following error occurs tr: write error: Illegal seekXanthin
@Xanthin Make sure you are starting cmd with administrator privilegesFreshen
I'm using git and my app is not in google play yet. I just create ocal jks key. But command can not find xxdJermyn
xxd.exe and tr.exe should be there right in C:\Program Files\Git\usr\bin for Windows or any equivalent directory if you are using mac or linuxFreshen
O
6

[UPDATED for windows]

# xxd
C:\Program Files\Git\usr\bin\xxd
# tr
C:\Program Files\Git\usr\bin\tr
# base64
C:\Program Files\Git\usr\bin\base64

The whole commands become

keytool -exportcert -alias YOUR_ALIAS -keystore certificate.jks | "C:\Program Files\Git\usr\bin\xxd" -p |"C:\Program Files\Git\usr\bin\tr" -d "[:space:]" | echo -n PACKAGE_NAME `cat` | "C:\Program Files\Git\usr\bin\sha256sum" | "C:\Program Files\Git\usr\bin\tr" -d "[:space:]-" | "C:\Program Files\Git\usr\bin\xxd" -r -p | "C:\Program Files\Git\usr\bin\base64" | "C:\Program Files\Git\usr\bin\cut" -c1-11
Obara answered 9/10, 2020 at 13:59 Comment(2)
That's true assuming that the user has all these commands installed under these paths. Worth trying, anyway.Eliza
Yaa. I should have mentioned that if somebody does not know the path of these then he/she can search his drives (probably C) to find its .exe file. The path of .exe file is the thing we are putting it there.Obara
V
2

In Window, if you are using SourceTree you will search with xxd.exe keyword or find it with C:\Users\your_user_name\AppData\Local\Atlassian\SourceTree\git_local\usr\bin path.

Example: keytool -alias MyKey -exportcert -keystore MyKey.keystore | C:\Users\your_user_name\AppData\Local\Atlassian\SourceTree\git_local\usr\bin\xxd -p | C:\Users\your_user_name\AppData\Local\Atlassian\SourceTree\git_local\usr\bin\tr -d "[:space:]"

You can download here

Vines answered 16/1, 2019 at 7:2 Comment(7)
Hi thanks, but I could not find Atlassian directory in C:\Users\your_user_name\AppData\Local\Freshen
Change the your_user_name to your username which you use to login the PCVines
You can download hereVines
I know that :p, Okay so I have installed Source tree, I can see Atlassian directory, but there is no git_local directoryFreshen
There is hg_local directoryFreshen
I give you a link to download it. Check my answer or my previous comment. Hope it helpsVines
Done. @john Thanks for the help.Freshen

© 2022 - 2024 — McMap. All rights reserved.