zoukankan      html  css  js  c++  java
  • RSA公钥格式PKCS#1,PKCS#8互转(微信获取RSA加密公钥)

           //把RSA公钥格式PKCS#1转换成PKCS#8
    org.bouncycastle.asn1.pkcs.RSAPublicKey rsaPublicKey = org.bouncycastle.asn1.pkcs.RSAPublicKey.getInstance(
    org.bouncycastle.util.encoders.Base64.decode(publicKeyString));
    
            java.security.spec.RSAPublicKeySpec publicKeySpec = new java.security.spec.RSAPublicKeySpec(rsaPublicKey.getModulus(), rsaPublicKey.getPublicExponent());
    
            java.security.KeyFactory keyFactory = java.security.KeyFactory.getInstance("RSA");
    
            java.security.PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);

    RSA公钥格式PKCS#1,PKCS#8互转说明(命令的方式)

    1. PKCS#1 转 PKCS#8:

    openssl rsa -RSAPublicKey_in -in <filename> -pubout

    1. PKCS#8 转 PKCS#1:

    openssl rsa -pubin -in <filename> -RSAPublicKey_out


    1. PKCS#1 格式密钥:

    -----BEGIN RSA PUBLIC KEY-----
    MIIBCgKCAQEArT82k67xybiJS9AD8nNAeuDYdrtCRaxkS6cgs8L9h83eqlDTlrdw
    zBVSv5V4imTq/URbXn4K0V/KJ1TwDrqOI8hamGB0fvU13WW1NcJuv41RnJVua0QA
    lS3tS1JzOZpMS9BEGeFvyFF/epbi/m9+2kUWG94FccArNnBtBqqvFncXgQsm98JB
    3a62NbS1ePP/hMI7Kkz+JNMyYsWkrOUFDCXAbSZkWBJekY4nGZtK1erqGRve8Jbx
    TWirAm/s08rUrjOuZFA21/EI2nea3DidJMTVnXVPY2qcAjF+595shwUKyTjKB8v1
    REPB3hPF1Z75O6LwuLfyPiCrCTmVoyfqjwIDAQAB
    -----END RSA PUBLIC KEY-----


    1. PKCS#8 格式密钥:

    -----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArT82k67xybiJS9AD8nNA
    euDYdrtCRaxkS6cgs8L9h83eqlDTlrdwzBVSv5V4imTq/URbXn4K0V/KJ1TwDrqO
    I8hamGB0fvU13WW1NcJuv41RnJVua0QAlS3tS1JzOZpMS9BEGeFvyFF/epbi/m9+
    lkUWG94FccArNnBtBqqvFncXgQsm98JB3a42NbS1ePP/hMI7Kkz+JNMyYsWkrOUF
    DCXAbSZkWBJekY4nGZtK1erqGRve8JbxTWirAm/s08rUrjOuZFA21/EI2nea3Did
    JMTVnXVPY2qcAjF+595shwUKyTjKB8v1REPB3hPF1Z75O6LwuLfyPiCrCTmVoyfq
    jwIDAQAB
    -----END PUBLIC KEY-----

    微信企业付款到银行卡(包含获取微信端的RSA公钥)参考文章:

    https://www.jianshu.com/p/efb1dcce6e4a

  • 相关阅读:
    Shell变量之自定义变量、环境变量
    Shell变量命名规则
    获取文件编码格式
    基于Lucene的文件检索Demo
    数据库压力测试工具
    插入ts以及判断列是否存在(支持多数据库)
    (摘)Chart属性设置
    (摘)C#comboBox绑定数据
    (摘)ORACLE DBA的职责
    (摘)DataGuard物理standby管理
  • 原文地址:https://www.cnblogs.com/xxj-bigshow/p/9860116.html
Copyright © 2011-2022 走看看