|
@@ -31,13 +31,19 @@ public class RsaUtils {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
RsaUtils rsa = new RsaUtils();
|
|
|
- KeyPairInfo keyPair = getKeyPair();
|
|
|
- String publicKey = keyPair.getPublicKey();
|
|
|
- String privateKey = keyPair.getPrivateKey();
|
|
|
- System.out.println("公钥:"+publicKey);
|
|
|
- System.out.println("私钥:"+privateKey);
|
|
|
-
|
|
|
- String ciphertext = rsa.encipher("abc", publicKey);
|
|
|
+// KeyPairInfo keyPair = getKeyPair();
|
|
|
+// String publicKey = keyPair.getPublicKey();
|
|
|
+// String privateKey = keyPair.getPrivateKey();
|
|
|
+// System.out.println("公钥:"+publicKey);
|
|
|
+// System.out.println("私钥:"+privateKey);
|
|
|
+
|
|
|
+ String ciphertext = rsa.encipher("{\n" +
|
|
|
+ " \"ryId\": 500,\n" +
|
|
|
+ " \"message\": \"Stream closed\",\n" +
|
|
|
+ " \"data\": null,\n" +
|
|
|
+ " \"success\": false,\n" +
|
|
|
+ " \"timestamp\": 1693293329143\n" +
|
|
|
+ "}", publicKey);
|
|
|
System.out.println(String.format("密文:"+ciphertext));
|
|
|
String deTxt = rsa.decipher(ciphertext, privateKey);
|
|
|
System.out.println(deTxt);
|