如何使用Google App签名为Sms检索器生成11个字符的哈希键 [英] How to generate 11 char hash key for Sms Retriever with Google App signing
问题描述
我已经使用AppSignatureHelper
类生成了11个字符的哈希.但是将apk上传到Play商店后,它们的哈希不再起作用.而且我发现Play用另一个替换了密钥,这就是为什么哈希值也被更改的原因.现在,我在获取11个字符的哈希键时遇到了麻烦.
I had generated the 11 char hash using the AppSignatureHelper
class. But after uploading the apk to play store, they hash doesn't work anymore. And I found out that Play replaces the key with another one which is why the hash gets changed as well. Now I'm having trouble getting the 11 char hash key.
我不知道如何使用Google提供的命令.我从此处
I don't know how to use the commands given by Google. I found this command from here
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
由于我的应用已启用Play应用签名,因此我将必须使用此命令
Since, Play App signing is enabled for my app, I'll have to use this command,
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
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
我已经用JDK的bin文件夹中的路径替换了keytool
,但是那是说xxd
无法识别,所以我从网站上下载了它,现在它说tr
无法识别,我想是的.我也会对cut
说.
I've replaced keytool
with its path from the JDK's bin folder but then it was saying xxd
was not recognized so I downloaded it from a website now it's saying tr
is not recognized, I guess it'll say that for cut
as well.
如果我问的太白痴,请原谅我,但是我该如何解决呢?
Please pardon me if it seems too noob of me asking it, but how can I resolve this?
更新:我已经在Linux机器上尝试了上面的第二个命令,该命令有效,并给了我11个字符的哈希值,但SMS检索程序仍然无法正常工作.
UPDATE: I've tried the second command from above on a linux machine, the command worked and gave me 11 character hash but still the SMS Retriever is not working.
解决方案::借助Nick Fortescue的答案,我下载了DER格式的文件.然后使用以下命令将其转换为.jks文件,
SOLUTION: With the help of Nick Fortescue's answer, I downloaded the DER formatted file. Then converted it to a .jks file using the following command,
keytool -importcert -alias myalias -file deployment_cert.der -keystore certificate.jks -storepass mypassword
然后从上方对certificate.jks执行了第一个命令,它就起作用了!
Then performed the first command from above on certificate.jks and it worked!
推荐答案
这是完整的分步指南.
- 转到播放控制台->打开应用->版本管理->应用签名->下载证书.就像下面的屏幕截图一样
这将为您提供 deployment_cert.der
文件
This will give you deployment_cert.der
file
- 将
deployment_cert.der
文件转换为.jks
文件
使用以下命令
keytool -importcert -alias YOUR_ALIAS -file deployment_cert.der -keystore certificate.jks -storepass YOUR_PASSWORD
将您在密钥库中使用的YOUR_ALIAS,YOUR_PASSWORD替换为您的密码.如果需要,请使用完整路径代替 deployment_cert.der
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
输入yes,然后单击enter.它将显示消息
type yes and click enter . It will show message
证书已添加到密钥库
Certificate was added to keystore
这将生成一个新文件 certificate.jks
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
将您的YOUR_ALIAS,YOUR_PACKAGE替换为密钥库,项目中使用的您的.如果需要,请使用完整路径代替 certificate.jks
Replace YOUR_ALIAS,YOUR_PACKAGE with yours which used in keystore,project . In place of certificate.jks
use complete path if required
它将要求输入密码
输入密钥库密码:mypassword
Enter keystore password: mypassword
输入密码,您将获得哈希值.
enter your password and you will get the hash .
如果您使用的是MacOS,则可以通过安装coreutils来安装sha256sum:
If you're using MacOS you can install sha256sum by installing coreutils like this:
brew install coreutils
或者您可以像这样使用shasum -a 256
代替sha256sum
:
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
Abhinav Gupta 和此问题的操作 Nick Fortescue
Credits to Abhinav Gupta and Op of this question Farhan Farooqui and above answer from Nick Fortescue
这篇关于如何使用Google App签名为Sms检索器生成11个字符的哈希键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!