import os
import shutil
KEY_LOCATION = "/Users/test/Documents/Android_workspace/Dancing/app/debug.jks"
KEY_ALIAS = "debug.jks"
KEY_PWD = "test123"
KEY_STORE_PWD = "test123"
KEY_DAYS = 10000
KEY_NEWPWD = "newtest123"
KEY_OPTION = 3
def readonly_handler(func, path, execinfo):
os.chmod(path, 128)
func(path)
def generateKeyStore():
if os.path.exists(KEY_LOCATION):
os.remove(KEY_LOCATION);
generateCommond = " keytool -genkey -alias " + KEY_ALIAS + " -keypass " + KEY_PWD + " -keyalg RSA -keysize 1024 -validity " + KEY_DAYS.__str__() + " -keystore " + KEY_LOCATION + " -storepass " + KEY_STORE_PWD + " -dname 'CN=test OU = 组织单位名称, O = 组织名称, L = 城市或区域名称, ST = 州或省份名称, C = cn'"
os.system(generateCommond);
def getKeyStoreFinger():
getFingerCommond = "keytool -list -v -keystore " + KEY_LOCATION + " -storepass " + KEY_STORE_PWD
os.system(getFingerCommond)
def modifyKeyStore():
modifyKeyStoreCommond = " keytool -storepasswd -keystore " + KEY_LOCATION + " -storepass " + KEY_LOCATION + " -new " + KEY_NEWPWD
os.system(modifyKeyStoreCommond)
if (KEY_OPTION == 1):
generateKeyStore()
elif (KEY_OPTION == 2):
getKeyStoreFinger()
elif (KEY_LOCATION == 3):
modifyKeyStore()