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
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
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;
}
}
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;
}
}
RSA算法的资料看看。