lizongbo opened a new issue, #28173:
URL: https://github.com/apache/shardingsphere/issues/28173

   ## Bug Report
   
   ### Which version of ShardingSphere did you use?
   5.2.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   ### Expected behavior
   encrypt ok
   ### Actual behavior
   ```
   java.lang.ClassNotFoundException: 
org.bouncycastle.pqc.math.linearalgebra.ByteUtils
        at java.net.URLClassLoader.findClass(URLClassLoader.java:387) 
~[?:1.8.0_382]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_382]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) 
~[?:1.8.0_382]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_382]
        at 
org.apache.shardingsphere.encrypt.sm.algorithm.SM3EncryptAlgorithm.encrypt(SM3EncryptAlgorithm.java:64)
 ~[shardingsphere-encrypt-sm-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.encrypt.sm.algorithm.SM3EncryptAlgorithm.encrypt(SM3EncryptAlgorithm.java:35)
 ~[shardingsphere-encrypt-sm-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptInsertValueParameterRewriter.encryptInsertValue(EncryptInsertValueParameterRewriter.java:114)
 ~[shardingsphere-encrypt-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptInsertValueParameterRewriter.encryptInsertValues(EncryptInsertValueParameterRewriter.java:88)
 ~[shardingsphere-encrypt-core-5.2.1.jar:5.2.1]
        at 
org.apache.shardingsphere.encrypt.rewrite.parameter.rewriter.EncryptInsertValueParameterRewriter.lambda$rewrite$1(EncryptInsertValueParameterRewriter.java:71)
 ~[shardingsphere-encrypt-core-5.2.1.jar:5.2.1]
   ```
   
   ### Reason analyze (If you can)
   class removed。
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   1. dependencies use:
   ```
       implementation  'org.bouncycastle:bcprov-jdk18on:1.75'
       implementation 
'org.apache.shardingsphere:shardingsphere-jdbc-spring-namespace-infra:5.2.1'
       implementation 
'org.apache.shardingsphere:shardingsphere-encrypt-spring-namespace:5.2.1'
       implementation 
'org.apache.shardingsphere:shardingsphere-sharding-spring-namespace:5.2.1'
       implementation 
'org.apache.shardingsphere:shardingsphere-parser-spring-namespace:5.2.1'
       implementation 
'org.apache.shardingsphere:shardingsphere-jdbc-core-spring-namespace:5.2.1
   ```
   
   2. xml config:
    ```
    <encrypt:encrypt-algorithm id="pwd_sm3encryptor" type="SM3">
       </encrypt:encrypt-algorithm>
   ```
   3.run test
   so get the exception
   
   4.check the jar, bcprov-jdk18on 
   org.bouncycastle.pqc.math.linearalgebra.ByteUtils is moved to 
org.bouncycastle.pqc.legacy.math.linearalgebra.ByteUtils.
   
   
   bug fix method:
   use  org.apache.commons.codec.binary.Hex to get hex string.
   
   test code:
    ```
       @Test
       void testToHexString() {
           String str = "shardingsm3";
           String hextStr1 = 
org.bouncycastle.pqc.legacy.math.linearalgebra.ByteUtils.toHexString(str.getBytes());
           System.out.println("hexStr1=" + hextStr1);
           String hexStr2 = 
org.apache.commons.codec.binary.Hex.encodeHexString(str.getBytes());
           System.out.println("hexStr2=" + hexStr2);
           assertEquals(hextStr1, hexStr2);
       }
    ```
   test result:
    ```
   hexStr1=7368617264696e67736d33
   hexStr2=7368617264696e67736d33
    ```
   
   
   


-- 
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