mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
refactor: V2 签名优化
This commit is contained in:
@@ -152,10 +152,11 @@ public abstract class BaseModel {
|
||||
*/
|
||||
@SneakyThrows
|
||||
private String hmacSha256(String src) {
|
||||
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
|
||||
SecretKeySpec secret_key = new SecretKeySpec(appSecret.getBytes(),"HmacSHA256");
|
||||
sha256_HMAC.init(secret_key);
|
||||
byte[] bytes = sha256_HMAC.doFinal(src.getBytes(StandardCharsets.UTF_8));
|
||||
String algorithm = "HmacSHA256";
|
||||
Mac sha256HMAC = Mac.getInstance(algorithm,"BC");
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(appSecret.getBytes(), algorithm);
|
||||
sha256HMAC.init(secretKeySpec);
|
||||
byte[] bytes = sha256HMAC.doFinal(src.getBytes(StandardCharsets.UTF_8));
|
||||
return Hex.toHexString(bytes).toUpperCase();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user