Skip to content

Commit 7226a95

Browse files
committed
修正base64换行问题
1 parent d665d46 commit 7226a95

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies {
1414
}
1515

1616
sourceCompatibility = 1.6
17-
version = '1.0'
17+
version = '1.1'
1818
group = "com.github.tencentyun"
1919
archivesBaseName = "tls-sig-api-v2"
2020
tasks.withType(JavaCompile) {

src/main/java/com/tencentyun/TLSSigAPIv2.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private String hmacsha256(String identifier, long currTime, long expire, String
3737
SecretKeySpec keySpec = new SecretKeySpec(byteKey, "HmacSHA256");
3838
hmac.init(keySpec);
3939
byte[] byteSig = hmac.doFinal(contentToBeSigned.getBytes("UTF-8"));
40-
return new BASE64Encoder().encode(byteSig);
40+
return (new BASE64Encoder().encode(byteSig)).replaceAll("\\s*", "");
4141
} catch (UnsupportedEncodingException e) {
4242
return "";
4343
} catch (NoSuchAlgorithmException e) {
@@ -74,7 +74,8 @@ private String genSig(String identifier, long expire, byte[] userbuf) {
7474
byte [] compressedBytes = new byte[2048];
7575
int compressedBytesLength = compressor.deflate(compressedBytes);
7676
compressor.end();
77-
return new String(Base64URL.base64EncodeUrl(Arrays.copyOfRange(compressedBytes, 0, compressedBytesLength)));
77+
return (new String(Base64URL.base64EncodeUrl(Arrays.copyOfRange(compressedBytes,
78+
0, compressedBytesLength)))).replaceAll("\\s*", "");
7879
}
7980

8081
public String genSig(String identifier, long expire) {

0 commit comments

Comments
 (0)