mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
uft-8 改为 StandardCharsets.UTF_8
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
@@ -180,7 +181,7 @@ public class AMapUtils {
|
||||
|
||||
Signature signature = Signature.getInstance("SHA256WithRSA");
|
||||
signature.initSign(priKey);
|
||||
signature.update(signContent.getBytes("UTF-8"));
|
||||
signature.update(signContent.getBytes(StandardCharsets.UTF_8));
|
||||
byte[] signed = signature.sign();
|
||||
return new String(Base64.getEncoder().encode(signed));
|
||||
}
|
||||
@@ -232,7 +233,7 @@ public class AMapUtils {
|
||||
PublicKey pubKey = keyFactory.generatePublic(new X509EncodedKeySpec(encodedKey));
|
||||
Signature signature = Signature.getInstance("SHA256WithRSA");
|
||||
signature.initVerify(pubKey);
|
||||
signature.update(content.getBytes("UTF-8"));
|
||||
signature.update(content.getBytes(StandardCharsets.UTF_8));
|
||||
return signature.verify(Base64.getDecoder().decode(sign.getBytes()));
|
||||
}
|
||||
|
||||
|
||||
@@ -862,7 +862,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataJson = JSONUtil.toJsonStr(data);
|
||||
|
||||
// 加密
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes("UTF-8"),
|
||||
byte[] encryptText = Cryptos.aesEncrypt(dataJson.getBytes(StandardCharsets.UTF_8),
|
||||
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||
String strData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
@@ -886,7 +886,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()),
|
||||
dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
|
||||
token = resultMap.get("AccessToken");
|
||||
// logger.info("token: {}", token);
|
||||
@@ -1616,7 +1616,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String dataString = checkResultMap.get("Data");
|
||||
// 解密data
|
||||
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIv.getBytes());
|
||||
String dataStr = new String(plainText, "UTF-8");
|
||||
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||
Map<String, String> resMap = (Map<String, String>) JSON.parse(dataStr);
|
||||
String secret = resMap.get("OperatorSecret");
|
||||
|
||||
|
||||
@@ -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