为 google 短信检索器 api 生成哈希字符串 - 'xxd' 未被识别为内部或外部命令

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

在 google 关于 SMS 和通话记录权限的新政策之后,我正在尝试为我的 android 应用程序实施 SMS 检索器 API。 该教程看起来很简单,但我在 creating/generating 哈希时发现了一个问题。

当我输入

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

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

它说:

'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.

https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string 页面

上没有可用的说明

谢谢。

在 Window 中,如果您使用 SourceTree,您将使用 xxd.exe 关键字搜索或使用 C:\Users\your_user_name\AppData\Local\Atlassian\SourceTree\git_local\usr\bin 路径查找。

示例: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:]"

您可以下载here

最后我设法获得了使用 SMS 检索器的哈希密钥 API - Android.

我遵循的步骤。

  1. 我使用的是 Git 所以它安装在我的机器上。前往 C:\Program Files\Git\usr\bin,我看到它有 xxd.exe 和 tr.exe,这是我的要求。

  2. 所以我把环境变量添加到 Path > New > C:\Program Files\Git\usr\bin

  3. 以管理员权限重启cmd。 xxd 和 tr 命令开始工作。

希望这对其他人有所帮助,因为 google 已停止 CALL_LOG、READ_SMS 权限。

干杯。

--------------------更新-------------------- -----

我在这里找到了另一个很好的答案。

请按照 link 给出的 创建哈希键的分步说明

我关注这个是因为发布应用到 play store 后生成的散列密钥不再起作用

希望对大家有所帮助!

[更新 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

整个命令变为

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