wangtuohang@126.com hai 1 mes
pai
achega
1e81df407c

+ 2 - 0
src/main/java/org/springblade/common/config/BladeConfiguration.java

@@ -65,6 +65,8 @@ public class BladeConfiguration implements WebMvcConfigurer {
 		secureRegistry.excludePathPatterns("/webjars/**");
 		secureRegistry.excludePathPatterns("/swagger-resources/**");
 		secureRegistry.excludePathPatterns("/druid/**");
+		secureRegistry.excludePathPatterns("/payInfo/wxLogin");
+		secureRegistry.excludePathPatterns("/payInfo/wxGetPhoneNumber");
 		return secureRegistry;
 	}
 

+ 25 - 0
src/main/java/org/springblade/common/utils/AsciiOrderUtil.java

@@ -0,0 +1,25 @@
+package org.springblade.common.utils;
+
+
+import com.fasterxml.jackson.databind.BeanDescription;
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
+import com.fasterxml.jackson.databind.ser.BeanSerializerModifier;
+
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * 通用工具类
+ *
+ * @author Chill
+ */
+public class AsciiOrderUtil extends BeanSerializerModifier {
+	@Override
+	public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
+													 BeanDescription beanDesc,
+													 List<BeanPropertyWriter> beanProperties) {
+		beanProperties.sort(Comparator.comparing(prop -> prop.getName()));
+		return beanProperties;
+	}
+}

+ 33 - 0
src/main/java/org/springblade/common/utils/MD5Util.java

@@ -0,0 +1,33 @@
+package org.springblade.common.utils;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * 通用工具类
+ *
+ * @author Chill
+ */
+public class MD5Util {
+
+	public static String getMD5Hash(String input) {
+		try {
+			// 获取MD5算法的MessageDigest实例
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			// 计算MD5哈希值
+			byte[] hashBytes = md.digest(input.getBytes());
+
+			// 将字节数组转换为十六进制字符串
+			StringBuilder sb = new StringBuilder();
+			for (byte b : hashBytes) {
+				sb.append(String.format("%02x", b));
+			}
+
+			// 返回大写的哈希值
+			return sb.toString().toUpperCase();
+		} catch (NoSuchAlgorithmException e) {
+			throw new RuntimeException("MD5 algorithm not found", e);
+		}
+	}
+}

+ 36 - 0
src/main/java/org/springblade/common/utils/SignUtil.java

@@ -0,0 +1,36 @@
+package org.springblade.common.utils;
+
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.Signature;
+import java.security.spec.KeySpec;
+import java.security.spec.PKCS8EncodedKeySpec;
+import java.util.Base64;
+
+/**
+ * 通用工具类
+ *
+ * @author Chill
+ */
+public class SignUtil {
+
+	//签名
+	public static String sign(String content, String privateKey) throws Exception {
+		return sign(content.getBytes("utf-8"), getPrivateKey(privateKey), "SHA256withRSA");
+	}
+
+	public static String sign(byte[] content, PrivateKey privateKey, String signInstance) throws Exception {
+		Signature signature = Signature.getInstance(signInstance);
+		signature.initSign(privateKey);
+		signature.update(content);
+		return Base64.getEncoder().encodeToString(signature.sign());
+	}
+
+	//生成私钥
+	public static PrivateKey getPrivateKey(String privateKey) throws Exception {
+		byte[] bytes = Base64.getDecoder().decode(privateKey);
+		KeySpec keySpec = new PKCS8EncodedKeySpec(bytes);
+		KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+		return keyFactory.generatePrivate(keySpec);
+	}
+}