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