This commit is contained in:
dimengzhe
2024-12-07 16:20:02 +08:00
parent 9ec1994dfc
commit cca0a8dc8b
2 changed files with 1 additions and 29 deletions

View File

@@ -106,34 +106,6 @@ public class Signature {
} }
} }
//获取签名
@PostMapping("/getSign2")
ResultBean<String> getSign2(@RequestParam("parameters") Map<String, String> parameters,
@RequestParam("appKey") String appKey,
@RequestParam("secret") String secret) {
ResultBean<String> rb = ResultBean.fireFail();
try {
// 1. 参数校验
if (parameters == null || parameters.isEmpty()) {
return rb.setMsg("Parameters cannot be empty.");
}
if (StringUtils.isEmpty(appKey)) {
return rb.setMsg("AppKey cannot be empty.");
}
if (StringUtils.isEmpty(secret)) {
return rb.setMsg("Secret cannot be empty.");
}
// 生成签名
String sign = SignatureUtil.generateSignature(parameters, appKey, secret);
return rb.success().setData(sign);
} catch (UnsupportedEncodingException e) {
return rb.setMsg("Unsupported encoding: " + e.getMessage());
} catch (NoSuchAlgorithmException e) {
return rb.setMsg("Algorithm not found: " + e.getMessage());
}
}
/** /**
* 对传入的参数集合进行签名处理 * 对传入的参数集合进行签名处理

View File

@@ -20,6 +20,6 @@ public class SignatureQuery {
//业务参数 //业务参数
private Map<String, String> parameters = new HashMap<>(); private Map<String, String> parameters = new HashMap<>();
//原签名值
private String receivedSignature; private String receivedSignature;
} }