zoukankan      html  css  js  c++  java
  • java-pfx文件转换成16进制内容

    public static void main(String[] args) throws Exception {
            String path = "D://111.pfx";
            InputStream in = new FileInputStream(new File(path));
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            KeyStore keyStore = KeyStore.getInstance("PKCS12");
            keyStore.load(in,"111".toCharArray());
            keyStore.store(out, "111".toCharArray());
            BASE64Encoder b = new BASE64Encoder();
            System.out.println(b.encode(out.toByteArray()));
        }

    这里如果知道pfx里的alias还可以取到私钥和证书。

    结果

    MIIJIgIBAzCCCNwGCSqGSIb3DQEHAaCCCM0EggjJMIIIxTCCA1IGCSqGSIb3DQEHAaCCA0MEggM/
    MIIDOzCCAzcGCyqGSIb3DQEMCgECoIICtjCCArIwHAYKKoZIhvcNAQwBAzAOBAhIpqQrmbCG+QIC
    B9AEggKQahOSv1h6dmpTiK61Ja5VRktfTSx5nG4sL/FDck2W501J28w3/wgTClAsQIlJDUhmvGiR
    pp+4/H3MV6Pyd150odom0EgwNLhPyCgNDpZZXN79yihTQDTIR9AKivOA8GJousKaeBwxT4Vjs4c2
    ZPXtxy11zSffsW+dQ/vWORUjfAvNyBW+MxwSlyNQXC45bfmfnr0VNBqwwf2vvz12zr4hqpiIvAud
    /yNlWplghWC0IVWSUId1WMVyj07ZcUTp2P+zGxw/2UJEyYadtt2xSn1SHM4d8gfFpL5oTbL1Nbh1
    sTWf00clum7VJkJItgq9S/NaVcsJESm0NeF1Z8p2OmzNQuo4mREkVxLzkh3bE7FXX8HNoMDTGZNZ
    nfRK5xs4jEkSsQjZfuYhg+1eeVwCDauF+HA7JhNhsvkByUG6OCGo4vmeKRYEuBxINEY8qrVKS7pE
    hfJTYwjuGqHVfQ1bESz9rIwgQK1BxjfFh88JErazDJw2UC6yTU0g0jDflUYMe2MP2rWhynx3Hz9a
    0a8/XiEOctytv4Y+crulOE+QJYqT6en7QQSjvi1W5BBMzcLpSfjIhj9yRqidaQT/4aU2yVQbUsOR
    RykSnJkGBqznMtrJiHrCORxn9b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MtAt
    8rhrNN9Po5P3ODhwt+7d3kgw3DqCM4naVhvXFWvSszfJBpOlPAmFVl0f6P6ml0ZqSU7uxdhUk+ws
    KWbo2NRTneM4p12XEoJWIChtAgf57/j9XycZ+5W6lu6x5r6KYIfS4doFZwukV3g9uVe0BNVNqA0w
    PTAhMAkGBSsOAwIaBQAEFL97g3fRHDwjgp+OCRMA+jmEiJbSBBSlvNFARIQ1GA0dr2yHu3TzZqPl
    7QICBAA=
    如果有使用请标明来源:http://www.cnblogs.com/duwenlei/
  • 相关阅读:
    洛谷.1110.[ZJOI2007]报表统计(Multiset Heap)
    洛谷.1110.[ZJOI2007]报表统计(Multiset)
    洛谷.3809.[模板]后缀排序(后缀数组 倍增) & 学习笔记
    洛谷.2801.教主的魔法(分块 二分)
    洛谷.2709.小B的询问(莫队)
    COGS.1901.[模板][国家集训队2011]数颜色(带修改莫队)
    COGS.1822.[AHOI2013]作业(莫队 树状数组/分块)
    COGS.1689.[HNOI2010]Bounce 弹飞绵羊(分块)
    COGS.264.数列操作(分块 单点加 区间求和)
    COGS.1317.数列操作c(分块 区间加 区间求和)
  • 原文地址:https://www.cnblogs.com/duwenlei/p/4022446.html
Copyright © 2011-2022 走看看