六、keytool工具

一个keytool的小工具.配置配置参数,挺方便希望能帮到大家.已经测试过的.keystore和jks都可以用
# -*- coding: utf-8 -*-
import os
import shutil

KEY_LOCATION = "/Users/test/Documents/Android_workspace/Dancing/app/debug.jks"
KEY_ALIAS = "debug.jks"
KEY_PWD = "test123" #password
KEY_STORE_PWD = "test123" #storepass
KEY_DAYS = 10000  #keystore的有效期
KEY_NEWPWD = "newtest123"  # 需要修改keystore才需要配置

KEY_OPTION = 3  # 1生成   2查询md5 sha1  3修改keystore


# 初始化一些变量
def readonly_handler(func, path, execinfo):
    os.chmod(path, 128)
    func(path)

#生成keystore
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);

#获取keystore的sha1 md5
def getKeyStoreFinger():
    getFingerCommond = "keytool -list -v -keystore " + KEY_LOCATION + " -storepass " + KEY_STORE_PWD
    os.system(getFingerCommond)

#修改keystore
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()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值