jt2594838 commented on code in PR #278:
URL: https://github.com/apache/tsfile/pull/278#discussion_r1821735279


##########
java/tsfile/src/main/java/org/apache/tsfile/encrypt/EncryptUtils.java:
##########
@@ -148,6 +144,48 @@ public static String getNormalKeyStr(TSFileConfig conf) {
     }
   }
 
+  public static EncryptParameter getEncryptParameter() {
+    String encryptType;
+    byte[] dataEncryptKey;
+    if (TSFileDescriptor.getInstance().getConfig().getEncryptFlag()) {
+      encryptType = 
TSFileDescriptor.getInstance().getConfig().getEncryptType();
+      try {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        md.update("IoTDB is the best".getBytes());
+        
md.update(TSFileDescriptor.getInstance().getConfig().getEncryptKey().getBytes());
+        dataEncryptKey = md.digest();
+      } catch (Exception e) {
+        throw new EncryptException(
+            "md5 function not found while using md5 to generate data key", e);
+      }
+    } else {
+      encryptType = "org.apache.tsfile.encrypt.UNENCRYPTED";
+      dataEncryptKey = null;
+    }
+    return new EncryptParameter(encryptType, dataEncryptKey);

Review Comment:
   May simplify with `return 
getEncryptParameter(TSFileDescriptor.getInstance().getConfig())` to reduce 
duplicated code.



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