|
|
@@ -0,0 +1,44 @@
|
|
|
+package com.xunmei.system.controller;
|
|
|
+
|
|
|
+import com.xunmei.system.util.Sm4Util;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Api(description = "中台", tags = {"sql 加解密"})
|
|
|
+@RestController
|
|
|
+@RequestMapping("/sql")
|
|
|
+public class SqlEncryptionAndDecryptionController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加密SQL
|
|
|
+ * @param sqlmap
|
|
|
+ */
|
|
|
+ @PostMapping("/encry")
|
|
|
+ public String encrySQL(@RequestBody Map<String, String> sqlmap) {
|
|
|
+ try {
|
|
|
+ return Sm4Util.encryptEcb("51d95b1dc43a9faaad0570f81c755fcf", sqlmap.get("sql"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 解密SQL
|
|
|
+ *
|
|
|
+ * @param sqlmap
|
|
|
+ */
|
|
|
+ @PostMapping("/decry")
|
|
|
+ public String decrySQL(@RequestBody Map<String, String> sqlmap) {
|
|
|
+ try {
|
|
|
+ return Sm4Util.decryptEcb("51d95b1dc43a9faaad0570f81c755fcf", sqlmap.get("sql"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|