From 3244b550596e0330031b3f4547356927df83b0ad Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期一, 19 五月 2025 11:48:35 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java |   79 ++++++---------------------------------
 1 files changed, 12 insertions(+), 67 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java
index 0f28ea6..e13282a 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/MD5Util.java
@@ -52,79 +52,24 @@
     public static String getMD5(String str) {
         if (StringUtils.isNotEmpty(str)) {
             try {
+                // 创建MD5加密实例
                 MessageDigest md = MessageDigest.getInstance("MD5");
-                md.update(str.getBytes());
-                byte b[] = md.digest();
-                int i;
-                StringBuffer buf = new StringBuffer("");
-                for (int offset = 0; offset < b.length; offset++) {
-                    i = b[offset];
-                    if (i < 0)
-                        i += 256;
-                    if (i < 16)
-                        buf.append("0");
-                    buf.append(Integer.toHexString(i));
+    
+                // 执行加密操作
+                byte[] messageDigest = md.digest(str.getBytes());
+    
+                // 将得到的散列值转换为十六进制
+                StringBuilder sb = new StringBuilder();
+                for (byte b : messageDigest) {
+                    sb.append(String.format("%02x", b));
                 }
-                //32位加密(小写)
-            return buf.toString();
-            //32位加密(大写)
-            //return buf.toString().toUpperCase();
-            // 16位的加密(小写)
-            //return buf.toString().substring(8, 24);
-            // 16位的加密(大写)
-            //return buf.toString().substring(8, 24).toUpperCase();
+    
+                // 返回MD5散列值
+                return sb.toString();
             } catch (NoSuchAlgorithmException e) {
                 e.printStackTrace();
             }
         }
-        return "";
-    }
- 
-    /**
-     * 获取32位大写
-     *
-     * @param str
-     * @return
-     */
-    public static String getMD5_32_upper(String str) {
-        if (StringUtils.isNotEmpty(str))
-            return getMD5(str).toUpperCase();
-        return "";
-    }
- 
-    /**
-     * 获取32位小写
-     *
-     * @param str
-     * @return
-     */
-    public static String getMD5_32_lower(String str) {
-        if (StringUtils.isNotEmpty(str))
-            return getMD5(str).toLowerCase();
-        return "";
-    }
- 
-    /**
-     * 获取16位大写
-     *
-     * @param str
-     * @return
-     */
-    public static String getMD5_16_upper(String str) {
-        if (StringUtils.isNotEmpty(str))
-            return getMD5(str).substring(8, 24).toUpperCase();
-        return "";
-    }
- 
-    /**
-     * 获取16位小写
-     *
-     * @param str
-     * @return
-     */
-    public static String getMD5_16_lower(String str) {
-        if (StringUtils.isNotEmpty(str))
-            return getMD5(str).substring(8, 24).toLowerCase();
         return "";
     }
  

--
Gitblit v1.7.1