You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/06/16 03:56:09 UTC

[GitHub] [shardingsphere] nanzheng opened a new pull request #10830: Update AESEncryptAlgorithm.java

nanzheng opened a new pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830


   improvement base64 encode decode performance. Totally increase almost over 200%
   
   Fixes apache Base64 encode decode low performance issue.
   
   Changes proposed in this pull request:
   -
   -
   -
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu merged pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu merged pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#issuecomment-870239458


   @nanzheng The checkstyle is failed, I just merge it and revise for you, please pay attention.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu merged pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu merged pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero commented on pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
tristaZero commented on pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#issuecomment-862054903


   Hi @nanzheng Thanks, If this PR can improve the performance, that will be appreciated. But could you look at non-passed CI tests?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#issuecomment-864781940


   > > Hi @nanzheng Thanks, If this PR can improve the performance, that will be appreciated. But could you look at non-passed CI tests?
   > 
   > Error: Failed to execute goal on project shardingsphere-infra-optimize: Could not resolve dependencies for project org.apache.shardingsphere:shardingsphere-infra-optimize:jar:5.0.0-RC1-SNAPSHOT: Failed to collect dependencies at org.apache.calcite:calcite-core:jar:1.26.0: Failed to read artifact descriptor for org.apache.calcite:calcite-core:jar:1.26.0: Could not transfer artifact org.apache.calcite:calcite-core:pom:1.26.0 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/calcite/calcite-core/1.26.0/calcite-core-1.26.0.pom: Connection reset -> [Help 1]
   > Error:
   > Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
   > Error: Re-run Maven using the -X switch to enable full debug logging.
   > Error:
   > Error: For more information about the errors and possible solutions, please read the following articles:
   > Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
   > Error:
   > Error: After correcting the problems, you can resume the build with the command
   > Error: mvn -rf :shardingsphere-infra-optimize
   > Error: Process completed with exit code 1.
   > CI building press got above errors, but there is nothing commit code import this infra module. Please help to find how does it happen. thanks.
   
   The error is related with #10810


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#issuecomment-870239458


   @nanzheng The checkstyle is failed, I just merge it and revise for you, please pay attention.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#issuecomment-864781940


   > > Hi @nanzheng Thanks, If this PR can improve the performance, that will be appreciated. But could you look at non-passed CI tests?
   > 
   > Error: Failed to execute goal on project shardingsphere-infra-optimize: Could not resolve dependencies for project org.apache.shardingsphere:shardingsphere-infra-optimize:jar:5.0.0-RC1-SNAPSHOT: Failed to collect dependencies at org.apache.calcite:calcite-core:jar:1.26.0: Failed to read artifact descriptor for org.apache.calcite:calcite-core:jar:1.26.0: Could not transfer artifact org.apache.calcite:calcite-core:pom:1.26.0 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/apache/calcite/calcite-core/1.26.0/calcite-core-1.26.0.pom: Connection reset -> [Help 1]
   > Error:
   > Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
   > Error: Re-run Maven using the -X switch to enable full debug logging.
   > Error:
   > Error: For more information about the errors and possible solutions, please read the following articles:
   > Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
   > Error:
   > Error: After correcting the problems, you can resume the build with the command
   > Error: mvn -rf :shardingsphere-infra-optimize
   > Error: Process completed with exit code 1.
   > CI building press got above errors, but there is nothing commit code import this infra module. Please help to find how does it happen. thanks.
   
   The error is related with #10810


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on a change in pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#discussion_r655120406



##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
##########
@@ -35,56 +32,63 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.Properties;
+import javax.xml.bind.DatatypeConverter;
+import java.io.UnsupportedEncodingException;
 
 /**
  * AES encrypt algorithm.
  */
 @Getter
 @Setter
 public final class AESEncryptAlgorithm implements EncryptAlgorithm {
-    
+
     private static final String AES_KEY = "aes-key-value";
-    
+
     private Properties props = new Properties();
-    
+
     private byte[] secretKey;
-    
+
     @Override
     public void init() {
         secretKey = createSecretKey();
     }
-    
+
     private byte[] createSecretKey() {
         Preconditions.checkArgument(props.containsKey(AES_KEY), String.format("%s can not be null.", AES_KEY));
         return Arrays.copyOf(DigestUtils.sha1(props.getProperty(AES_KEY)), 16);
     }
-    
+
     @SneakyThrows(GeneralSecurityException.class)
     @Override
     public String encrypt(final Object plaintext) {
         if (null == plaintext) {
             return null;
         }
-        byte[] result = getCipher(Cipher.ENCRYPT_MODE).doFinal(StringUtils.getBytesUtf8(String.valueOf(plaintext)));
-        return Base64.encodeBase64String(result);
+        byte[] result = new byte[0];
+        try {
+            result = getCipher(Cipher.ENCRYPT_MODE).doFinal(String.valueOf(plaintext).getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();

Review comment:
       Please do not use `printStackTrace`, it is better to process exception appropriately

##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
##########
@@ -35,56 +32,63 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.Properties;
+import javax.xml.bind.DatatypeConverter;
+import java.io.UnsupportedEncodingException;
 
 /**
  * AES encrypt algorithm.
  */
 @Getter
 @Setter
 public final class AESEncryptAlgorithm implements EncryptAlgorithm {
-    
+

Review comment:
       Please do not change the original indent, please just change necessary codes.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on a change in pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#discussion_r658568930



##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
##########
@@ -59,14 +56,15 @@ public void init() {
         return Arrays.copyOf(DigestUtils.sha1(props.getProperty(AES_KEY)), 16);
     }
     
-    @SneakyThrows(GeneralSecurityException.class)
+    @SneakyThrows

Review comment:
       Please SneakyThrows accurate exception 




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] terrymanu commented on a change in pull request #10830: Update AESEncryptAlgorithm.java

Posted by GitBox <gi...@apache.org>.
terrymanu commented on a change in pull request #10830:
URL: https://github.com/apache/shardingsphere/pull/10830#discussion_r655120406



##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
##########
@@ -35,56 +32,63 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.Properties;
+import javax.xml.bind.DatatypeConverter;
+import java.io.UnsupportedEncodingException;
 
 /**
  * AES encrypt algorithm.
  */
 @Getter
 @Setter
 public final class AESEncryptAlgorithm implements EncryptAlgorithm {
-    
+
     private static final String AES_KEY = "aes-key-value";
-    
+
     private Properties props = new Properties();
-    
+
     private byte[] secretKey;
-    
+
     @Override
     public void init() {
         secretKey = createSecretKey();
     }
-    
+
     private byte[] createSecretKey() {
         Preconditions.checkArgument(props.containsKey(AES_KEY), String.format("%s can not be null.", AES_KEY));
         return Arrays.copyOf(DigestUtils.sha1(props.getProperty(AES_KEY)), 16);
     }
-    
+
     @SneakyThrows(GeneralSecurityException.class)
     @Override
     public String encrypt(final Object plaintext) {
         if (null == plaintext) {
             return null;
         }
-        byte[] result = getCipher(Cipher.ENCRYPT_MODE).doFinal(StringUtils.getBytesUtf8(String.valueOf(plaintext)));
-        return Base64.encodeBase64String(result);
+        byte[] result = new byte[0];
+        try {
+            result = getCipher(Cipher.ENCRYPT_MODE).doFinal(String.valueOf(plaintext).getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();

Review comment:
       Please do not use `printStackTrace`, it is better to process exception appropriately

##########
File path: shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-core/src/main/java/org/apache/shardingsphere/encrypt/algorithm/AESEncryptAlgorithm.java
##########
@@ -35,56 +32,63 @@
 import java.security.NoSuchAlgorithmException;
 import java.util.Arrays;
 import java.util.Properties;
+import javax.xml.bind.DatatypeConverter;
+import java.io.UnsupportedEncodingException;
 
 /**
  * AES encrypt algorithm.
  */
 @Getter
 @Setter
 public final class AESEncryptAlgorithm implements EncryptAlgorithm {
-    
+

Review comment:
       Please do not change the original indent, please just change necessary codes.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org