如何获取我的APK的签名校验和? [英] How do I get the signature checksum of my APK?
问题描述
在为设备所有者应用程序配置设备时,我想使用签名校验和而不是程序包校验和.该应用程序将从http服务器下载.
I would like to use the signature checksum instead of the package checksum when provisioning a device with a device owner app. The app will be downloaded from an http server.
使用EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM时,该帖子很棒: 配置Android Lollipop时的校验和错误
This post is great when using EXTRA_PROVISIONING_DEVICE_ADMIN_PACKAGE_CHECKSUM: Checksum Error while provisioning Android Lollipop
但是我想使用EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM. 请参阅: https://developer.android.com/reference/android/app/admin/DevicePolicyManager.htm
But I would like to use EXTRA_PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM. See: https://developer.android.com/reference/android/app/admin/DevicePolicyManager.htm
预配应用程序和设备所有者应用程序都将在Android O上运行.
The provisioning app and device owner app will both on be running on Android O.
如何获取可在NFC的键/值对中使用的应用程序的签名校验和?
How do I get the signature checksum of my app that I can use in my key/value pair for NFC?
推荐答案
尝试一下
keytool -list -printcert -jarfile [path_to_your_apk] | grep -Po "(?<=SHA256:) .*" | xxd -r -p | openssl base64 | tr -d '=' | tr -- '+/=' '-_'
详细信息:
-
keytool -list -printcert -jarfile [path_to_your_apk]
提取有关APK证书的信息, -
grep -Po "(?<=SHA256:) .*" | xxd -r -p
提取SHA256哈希并将其转换为二进制, -
openssl base64
使用base64对其进行编码, -
tr -d '=' | tr -- '+/=' '-_'
使其具有URL安全性(+
编码为-
,/
编码为_
,并且删除了填充字符=
).
keytool -list -printcert -jarfile [path_to_your_apk]
extracts informations about the certificate of the APK,grep -Po "(?<=SHA256:) .*" | xxd -r -p
takes the SHA256 hash and converts it to binary,openssl base64
encodes it with base64,tr -d '=' | tr -- '+/=' '-_'
makes it URL-safe (+
is encoded as-
,/
is encoded as_
and the padding character=
is removed).
这篇关于如何获取我的APK的签名校验和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!