Skip to content

Commit 3b1b2f1

Browse files
committed
Improve the servicesignature performance.
1 parent 6dfc15a commit 3b1b2f1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/com/aliyun/oss/common/auth/HmacSHA1Signature.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ public String computeSignature(String key, String data) {
6464
public byte[] computeHash(byte[] key, byte[] data) {
6565
return sign(key, data, macInstance, LOCK, ALGORITHM);
6666
}
67+
68+
static {
69+
try {
70+
macInstance = Mac.getInstance(ALGORITHM);
71+
} catch (Throwable e) {
72+
}
73+
}
6774
}

src/main/java/com/aliyun/oss/common/auth/HmacSHA256Signature.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ public String computeSignature(String key, String data) {
6464
public byte[] computeHash(byte[] key, byte[] data) {
6565
return sign(key, data, macInstance, LOCK, ALGORITHM);
6666
}
67+
68+
static {
69+
try {
70+
macInstance = Mac.getInstance(ALGORITHM);
71+
} catch (Throwable e) {
72+
}
73+
}
6774
}

0 commit comments

Comments
 (0)