From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 01 八月 2025 13:27:59 +0800
Subject: [PATCH] yys 密码已重置

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/GZipUtil.java |   61 ++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/GZipUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/GZipUtil.java
new file mode 100644
index 0000000..20a9da5
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/GZipUtil.java
@@ -0,0 +1,61 @@
+package com.ruoyi.common.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * 鍘嬬缉瑙e帇宸ュ叿绫�
+ */
+public class GZipUtil {
+
+
+    /**
+     * 鍘嬬缉
+     * @param str
+     * @return
+     */
+    public static String compress(String str) {
+        if (str == null || str.trim().length() == 0) {
+            return null;
+        }
+
+        try (ByteArrayOutputStream out = new ByteArrayOutputStream();
+             GZIPOutputStream gzip = new GZIPOutputStream(out)) {
+            gzip.write(str.getBytes("utf-8"));
+            gzip.close();
+
+            return new String(out.toByteArray(), "iso-8859-1");
+        } catch (Exception e) {
+            throw new RuntimeException("鏁版嵁鍘嬬缉澶辫触");
+        }
+
+    }
+
+    /**
+     * 瑙e帇
+     * @param str
+     * @return
+     */
+    public static String uncompress(String str) {
+        if (str == null || str.trim().length() == 0) {
+            return null;
+        }
+
+        try (ByteArrayOutputStream out = new ByteArrayOutputStream();
+             ByteArrayInputStream in = new ByteArrayInputStream(str.getBytes("iso-8859-1"))){
+            GZIPInputStream ungzip = new GZIPInputStream(in);
+            byte[] buffer = new byte[1024];
+            int n;
+            while ((n = ungzip.read(buffer)) >= 0) {
+                out.write(buffer, 0, n);
+            }
+
+            return new String(out.toByteArray(), "utf-8");
+        } catch (Exception e) {
+            throw new RuntimeException("鏁版嵁瑙e帇澶辫触");
+        }
+
+    }
+}

--
Gitblit v1.9.3