mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-02 00:49:59 +08:00
uft-8 改为 StandardCharsets.UTF_8
This commit is contained in:
@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
|
||||
public class GBSignUtils {
|
||||
@@ -42,7 +43,7 @@ public class GBSignUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] HmacMD5Encrypt(String encryptText, String encryptKey) throws Exception {
|
||||
byte[] data = encryptKey.getBytes("UTF-8");
|
||||
byte[] data = encryptKey.getBytes(StandardCharsets.UTF_8);
|
||||
// 根据给定的字节数组构造一个密钥,第二参数指定一个密钥算法的名称
|
||||
SecretKey secretKey = new SecretKeySpec(data, "HmacMD5");
|
||||
// 生成一个指定 Mac 算法 的 Mac 对象
|
||||
@@ -50,7 +51,7 @@ public class GBSignUtils {
|
||||
// 用给定密钥初始化 Mac 对象
|
||||
mac.init(secretKey);
|
||||
|
||||
byte[] text = encryptText.getBytes("UTF-8");
|
||||
byte[] text = encryptText.getBytes(StandardCharsets.UTF_8);
|
||||
// 完成 Mac 操作
|
||||
return mac.doFinal(text);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.jsowell.common.util.DateUtils;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@@ -28,10 +29,10 @@ public class LianLianUtils {
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String encryptionHMAC(String source) throws Exception {
|
||||
SecretKey secretKey = new SecretKeySpec(MAC_KEY.getBytes("UTF-8"), ALGORITHM_MAC);
|
||||
SecretKey secretKey = new SecretKeySpec(MAC_KEY.getBytes(StandardCharsets.UTF_8), ALGORITHM_MAC);
|
||||
Mac mac = Mac.getInstance(ALGORITHM_MAC);
|
||||
mac.init(secretKey);
|
||||
mac.update(source.getBytes("UTF-8"));
|
||||
mac.update(source.getBytes(StandardCharsets.UTF_8));
|
||||
return BytesUtil.binary(mac.doFinal(), 16).toUpperCase(Locale.ROOT);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user