马上注册,解锁更多高级玩法
您需要 登录 才可以下载或查看,没有账号?立即注册
×
获取APK当前签名文件的SHA1
[JavaScript] 纯文本查看 复制代码 function getSelfSHA1() {
importClass(java.security.MessageDigest)
importClass(java.lang.StringBuffer)
importClass(android.content.pm.PackageManager)
importClass(java.util.Locale)
let publicKey = MessageDigest.getInstance("SHA1").digest(context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES).signatures[0].toByteArray())
let hexString = new StringBuffer()
for (let i = 0; i < publicKey.length; i++) {
let appendString = java.lang.Integer.toHexString(0xff & publicKey[i]).toUpperCase(Locale.US)
if (appendString.length === 1) hexString.append("0")
hexString.append(appendString)
}
return hexString.toString() + ""
}
|