如何使用 Google App 签名为 Sms Retriever 生成 11 个字符的哈希密钥 [英] How to generate 11 char hash key for Sms Retriever with Google App signing
问题描述
我使用 AppSignatureHelper
类生成了 11 个字符的哈希值.但是在将 apk 上传到 Play 商店后,它们的哈希不再起作用.我发现 Play 用另一个密钥替换了密钥,这就是哈希值也被更改的原因.现在我无法获取 11 个字符的哈希键.
我不知道如何使用 Google 给出的命令.我从
这会给你deployment_cert.der
文件
- 将
deployment_cert.der
文件转换为.jks
文件
使用下面的命令
keytool -importcert -alias YOUR_ALIAS -file deployment_cert.der -keystore certificate.jks -storepass YOUR_PASSWORD
将 YOUR_ALIAS,YOUR_PASSWORD 替换为您在 keystore 中使用的.如果需要,请使用完整路径代替 deployment_cert.der
输入此命令后会询问
<块引用>信任这个证书?[否]:是
输入 yes 并点击 enter .它将显示消息
<块引用>证书已添加到密钥库
这将生成一个新文件 certificate.jks
现在在终端输入命令
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 替换为您在 keystore,project 中使用的.如果需要,代替 certificate.jks
使用完整路径
它会要求输入密码
<块引用>输入密钥库密码:mypassword
输入您的密码,您将获得哈希值.
编辑 MacOS 用户:
如果您使用的是 MacOS,您可以通过像这样安装 coreutils 来安装 sha256sum:
brew install coreutils
或者你可以像这样使用 shasum -a 256
而不是 sha256sum
:
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 和此问题的操作 Farhan Farooqui 及以上来自 Nick Fortescue
的回答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.
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
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
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?
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.
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
Then performed the first command from above on certificate.jks and it worked!
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
这篇关于如何使用 Google App 签名为 Sms Retriever 生成 11 个字符的哈希密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!