KeyModulus: 8086696086674940284145398431542053944772851104336837006578908166207155276886761298301538589368449778994206593916683790075938024404216186895534478830159739 
PublicExponent: 65537 
PrivateExponent: 2660933535394435009652494273100758248302890490334069152492090797629694730397471916967117148094332593617331754319156925210125408626169706287189010975649193 
pubKey.equals(pubKey1): true 
priKeyModulus.equals(priKey1Modulus): true 
priKeyPrivateExponent.equals(priKey1PrivateExponent): true 
orgData: 010101 
pubKey encrypt: 4CB686E13E5B0D0A501005AB27ACAE9EC49A9F6117E4E45DB3502EA43AE430BE51E91EC3A6B48E96D778475D938FCD8DECC4467861643CED89F6CE4B37FB2768 
priKey decrypt: 010101 
orgData: 010101 
pubKey1 encrypt: 5B1A802C03489028D0F936AFE72E924331BC4821FE04733B5F64BEDBD0E4701FEC8CE52701A66EB464ABAD10E4B48A09BEAA1A496DE4783095C823C5766D3342 
priKey1 decrypt: 010101 

解决方案 »

  1.   

    加密的方法 public byte[] encrypt(byte[] data,PublicKey pubKey) {
    try {
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE, pubKey);
    byte[] cipherData = cipher.doFinal(data);
    return cipherData;
    } catch (Exception e) {
    e.printStackTrace();
    return null;
    }
    }
      

  2.   


    public byte[] encrypt(byte[] data,PublicKey pubKey) {
    try {
    Cipher cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.ENCRYPT_MODE, pubKey);
    byte[] cipherData = cipher.doFinal(data);
    return cipherData;
    } catch (Exception e) {
    e.printStackTrace();
    return null;
    }
    }
      

  3.   

    你用的rsa算法,加密时用的公钥和还私钥啊,这两种密钥加密出来的密文当然不一样
      

  4.   

    用的同一个公钥,只是构造的方式不一样,但是pubKey.equals(pubKey1): true
      

  5.   

    每次加密内容不一样是正常的,这是RSA算法就是这样实现的,有兴趣可以去查下
    RSA算法的资料看看。