niejian commented on issue #3799:
URL: https://github.com/apache/shenyu/issues/3799#issuecomment-1208847315

   默认使用`RSA`加密,需要在使用该插件之前生成公钥、私钥对;可参考
   
   * 生成公钥私钥
   
   ```java
   public static void genKeyPair() throws NoSuchAlgorithmException {
           // KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
           KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
   
           // 初始化密钥对生成器,密钥大小为96-2048位
           keyPairGen.initialize(2048, new SecureRandom());
   
           // 生成一个密钥对,保存在keyPair中
           KeyPair keyPair = keyPairGen.generateKeyPair();
           RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();     
// 得到私钥
           RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();         
        // 得到公钥
   
   //        // 得到公钥字符串
   //        String publicKeyStr = new String(publicKey.getEncoded());
   //        // 得到私钥字符串
   //        String privateKeyStr = new String((privateKey.getEncoded()));
   
           // 得到公钥字符串
           String publicKeyStr = new 
String(Base64.encodeBase64(publicKey.getEncoded()));
           // 得到私钥字符串
           String privateKeyStr = new 
String(Base64.encodeBase64((privateKey.getEncoded())));
   
   
           System.out.println("随机生成的公钥为:" + publicKeyStr);
           System.out.println("随机生成的私钥为:" + privateKeyStr);
       }
   ```
   * 将公钥私钥填入对应的位置
     `encryKey` -> `公钥`
     `decrypKey` -> `私钥`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to