[MINOR UPDATE] Use Encode to string when possible (Base64) (#3016)

Co-authored-by: aias00 <rokkki@163.com>
Co-authored-by: tomsun28 <tomsun28@outlook.com>
This commit is contained in:
PJ Fanning
2025-01-24 18:44:14 +08:00
committed by GitHub
co-authored by aias00 tomsun28
parent 2f3abfbad4
commit 12ba2faa19
2 changed files with 3 additions and 3 deletions
@@ -90,7 +90,7 @@ public final class AesUtil {
// encode content to byte array
byte[] byteAes = cipher.doFinal(byteEncode);
// base64 encode content
return new String(Base64.getEncoder().encode(byteAes), StandardCharsets.UTF_8);
return Base64.getEncoder().encodeToString(byteAes);
} catch (Exception e) {
log.error("aes encode content error: {}", e.getMessage(), e);
return content;
@@ -194,9 +194,9 @@ public class ServiceAccountService {
private HttpHeaders createHeaders() {
String auth = username + SignConstants.DOUBLE_MARK + password;
byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
String encodedAuth = Base64.getEncoder().encodeToString(auth.getBytes(StandardCharsets.UTF_8));
String authHeader = NetworkConstants.BASIC
+ SignConstants.BLANK + new String(encodedAuth);
+ SignConstants.BLANK + encodedAuth;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);