tsurumure преди 7 месеца
родител
ревизия
a4ee9f9ce2
променени са 2 файла, в които са добавени 7 реда и са изтрити 2 реда
  1. 3 0
      db/sys_dictionary.sql
  2. 4 2
      src/main/java/com/backendsys/service/KeyPair/KeyPairServiceImpl.java

+ 3 - 0
db/sys_dictionary.sql

@@ -27,6 +27,9 @@ INSERT INTO sys_dictionary(category_value, key_value, key_translation, key_trans
     ('AuditStatus', -1, '审核拒绝', 'Audit Rejection'),
     ('AuditStatus', 1, '待审核', 'Wait Audit'),
     ('AuditStatus', 2, '审核通过', 'Audit Passed'),
+    ('MenuType', 1, '菜单', 'Menu'),
+    ('MenuType', 2, '按钮', 'Button'),
+
     ('IsStock', -1, '无限', 'Infinite'),
     ('IsStock', 1, '有限', 'Limited'),
     ('WarehouseType', 1, '正常', 'Normal'),

+ 4 - 2
src/main/java/com/backendsys/service/KeyPair/KeyPairServiceImpl.java

@@ -8,6 +8,7 @@ import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NoSuchPaddingException;
+import java.nio.charset.StandardCharsets;
 import java.security.*;
 import java.security.spec.InvalidKeySpecException;
 import java.security.spec.PKCS8EncodedKeySpec;
@@ -78,8 +79,9 @@ public class KeyPairServiceImpl implements KeyPairService{
             // 使用公钥来加密数据
             Cipher cipher = Cipher.getInstance("RSA");
             cipher.init(Cipher.ENCRYPT_MODE, publicKey);
-            byte[] encryptedData = cipher.doFinal(content.getBytes());
-            String encryptedString = new String(encryptedData);
+            byte[] encryptedData = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8));
+            // 将加密后的字节数组转换为 Base64 编码
+            String encryptedString = Base64.getEncoder().encodeToString(encryptedData);
             return encryptedString;
         } catch (NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
             throw new CustException(e.getMessage());