5

快速用谷歌提供的签名生成Facebook登录所需的Hash值

 3 years ago
source link: https://xmanyou.com/generate-facebook-login-hash-key-from-google-sign-sha1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
13 August 2021 / android

快速用谷歌提供的签名生成Facebook登录所需的Hash值

谷歌后台提供了签名的托管服务,用于对上传的发布包进行重新签名。

接入Facebook登录功能时,根据文档,需要提供游戏包签名秘钥的hash串。如果是自己的key store,可以用以下命令来生成:

keytool -exportcert -alias <别名> -keystore <key store文件> | openssl sha1 -binary | openssl base64

如果没有添加谷歌托管签名服务对应秘钥的hash值,而直接将游戏上线,会导致Facebook登录功能失败:
fb-login-invalid-hash-key

由于谷歌的托管服务没有提供key store文件,只提供了sha-1等的二进制表示串,没法用Facebook提供的命令来获取hash值,这可怎么办呢?

Stackoverflow上,有人提供了个快速的方法,详细步骤:

  • 1). 打开浏览器的开发者工具
  • 2). 切换到console控制台
  • 3). 输入以下命令
btoa('签名的SHA-1值'.split(':').map(hc => String.fromCharCode(parseInt(hc, 16))).join(''))

就会输出Facebook所需的hash值了。

fb-login-invalid-hash-key2

  • hex map 转换成 base64
btoa('a7:77:d9:20:c8:01:dd:fa:2c:3b:db:b2:ef:c5:5a:1d:ae:f7:28:6f'.split(':').map(hc => String.fromCharCode(parseInt(hc, 16))).join(''))
  • base64 转换 hex map
atob('p3fZIMgB3fosO9uy78VaHa73KG8=').split('').map(c => c.charCodeAt(0).toString(16)).join(':')

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK