1.pk8 および x509.pem は jks を生成します
https://blog.csdn.net/laipigui905/article/details/112347159
2.jks sha256を見る
- keytool -list -v -keystore xxx.jks
- キーを入力してください
3.apk sha256 を表示する
- apkを解凍します
- keytool -printcert -file xxx\META-INF\CERT.RSA
4. Python を使用して APK の署名を表示する
# -*- coding: utf-8 -*-
#coding:utf-8
from cProfile import run
import os
from subprocess import call
import sys
import zipfile
# 解压出来的路径
def getExtractPath(apkPath):
return apkPath + "_files/"
# 解压apk
def un_zip(apk_path, extract_path):
print("unzip:", apk_path)
zip_file = zipfile.ZipFile(apk_path)
if os.path.isdir(extract_path):
pass
else:
os.mkdir(extract_path)
for names in zip_file.namelist():
zip_file.extract(names, extract_path)
zip_file.close()
# 获取签名信息
def getSignatureSha256(extractPath):
certRSAPath = extractPath + "/META-INF/CERT.RSA"
outputPath = extractPath + "/sign.txt"
cmd = "keytool -printcert -file " + certRSAPath + " > " + outputPath
call("keytool -printcert -file " + certRSAPath)
return os.system(cmd)
# 读取sha256
def readSignatureSha256(extractPath):
outputPath = extractPath + "/sign.txt"
for line in open(outputPath):
if(line.__contains__("SHA256")):
return line.strip()
argv = sys.argv[1:]
print(argv)
apkPath = argv[0]
extractPath = getExtractPath(apkPath)
un_zip(apkPath , extractPath)
getSignatureSha256(extractPath)
sha256 = readSignatureSha256(extractPath)
print(sha256)