于俊龙 2 weeks ago
parent
commit
8b2f996bf2

+ 5 - 12
farm-common/src/main/java/jp/yamoto/farm/common/utils/DecryptUtils.java

@@ -27,7 +27,8 @@ public class DecryptUtils {
     /**
      * AES 暗号化
      */
-    public static String encryptAES(String data, String key) throws Exception {
+    public static String encryptAES(String data) throws Exception {
+        String key = AppConfig.getDecryptFieldKey();
         byte[] keyBytes = Base64.getDecoder().decode(key);
         SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, AES_ALGORITHM);
 
@@ -52,7 +53,8 @@ public class DecryptUtils {
      * AES 暗号化されたテキストを復号します。
      *
      */
-    public static String decryptAES(String encryptedData, String key) throws Exception {
+    public static String decryptAES(String encryptedData) throws Exception {
+        String key = AppConfig.getDecryptFieldKey();
         byte[] combined = Base64.getDecoder().decode(encryptedData);
         byte[] keyBytes = Base64.getDecoder().decode(key);
         SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, AES_ALGORITHM);
@@ -97,7 +99,7 @@ public class DecryptUtils {
 //                base64Encoded += "=";
 //            }
 
-            return decryptAES(encryptedText, AppConfig.getDecryptFieldKey());
+            return decryptAES(encryptedText);
 
 //
 //            // Base64文字列をデコード
@@ -122,13 +124,4 @@ public class DecryptUtils {
             return encryptedText;
         }
     }
-
-    public static void main(String[] args) throws Exception {
-        String key = "rtKDbersTvuTdyhbadsddd";
-        String s = DecryptUtils.encryptAES("abdafasdc@nextosd.com", key);
-
-        System.out.println(s);
-
-        System.out.println(DecryptUtils.decryptAES(s, key));
-    }
 }