From eb6b6dbb35a9f029e0b7d269773685c19fd40976 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 11 七月 2024 10:47:51 +0800
Subject: [PATCH] 玩湃微信商户认证代码

---
 cloud-server-other/src/main/java/com/dsh/other/util/akeylogin/SignUtil.java |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/cloud-server-other/src/main/java/com/dsh/other/util/akeylogin/SignUtil.java b/cloud-server-other/src/main/java/com/dsh/other/util/akeylogin/SignUtil.java
new file mode 100644
index 0000000..4e882e5
--- /dev/null
+++ b/cloud-server-other/src/main/java/com/dsh/other/util/akeylogin/SignUtil.java
@@ -0,0 +1,24 @@
+package com.dsh.other.util.akeylogin;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+public class SignUtil {
+    private static String charset = "utf8";
+
+    public static String getSign(Map<String, Object> data, String secret) {
+        if (data == null) {
+            return null;
+        }
+        //排序参数
+        Map<String, Object> mappingList = new TreeMap<>(data);
+        StringBuilder plainText = new StringBuilder();
+        mappingList.forEach((k, v) -> {
+            if (!"sign".equals(k) && !BaseUtils.isEmpty(v)) {
+                plainText.append(String.format("%s=%s&", k, v));
+            }
+        });
+        String substring = plainText.substring(0, plainText.length() - 1);
+        return Md5Util.MD5Encode(substring + secret, charset);
+    }
+}

--
Gitblit v1.7.1