瀏覽代碼

更新!

TRX 1 年之前
父節點
當前提交
585090e015
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/util/AesUtils.java

+ 16 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/util/AesUtils.java

@@ -53,6 +53,22 @@ public class AesUtils {
         return new String(Base64.getEncoder().encode(encryptedBytes));
     }
 
+    /**
+     * aes 解密
+     *
+     * @param data
+     * @param SECRET_KEY
+     * @return
+     * @throws Exception
+     */
+    public static String decryptAes(String data, String SECRET_KEY) throws Exception {
+        Cipher cipher = Cipher.getInstance("AES");
+        SecretKeySpec secretKeySpec = new SecretKeySpec(SECRET_KEY.getBytes(), "AES");
+        cipher.init(Cipher.DECRYPT_MODE, secretKeySpec);
+        byte[] encryptedBytes = cipher.doFinal(data.getBytes());
+        return new String(Base64.getDecoder().decode(encryptedBytes));
+    }
+
     @SneakyThrows
     public static String signMacSHA256(String str, String key) {
         Mac mac = Mac.getInstance("HmacSHA256");