diff --git a/src/main/java/com/aliyun/oss/common/auth/HmacSHA1Signature.java b/src/main/java/com/aliyun/oss/common/auth/HmacSHA1Signature.java index da3e3e5b..16cc1598 100644 --- a/src/main/java/com/aliyun/oss/common/auth/HmacSHA1Signature.java +++ b/src/main/java/com/aliyun/oss/common/auth/HmacSHA1Signature.java @@ -64,4 +64,11 @@ public String computeSignature(String key, String data) { public byte[] computeHash(byte[] key, byte[] data) { return sign(key, data, macInstance, LOCK, ALGORITHM); } + + static { + try { + macInstance = Mac.getInstance(ALGORITHM); + } catch (Throwable e) { + } + } } \ No newline at end of file diff --git a/src/main/java/com/aliyun/oss/common/auth/HmacSHA256Signature.java b/src/main/java/com/aliyun/oss/common/auth/HmacSHA256Signature.java index 2b5c83f9..de3b81e8 100644 --- a/src/main/java/com/aliyun/oss/common/auth/HmacSHA256Signature.java +++ b/src/main/java/com/aliyun/oss/common/auth/HmacSHA256Signature.java @@ -64,4 +64,11 @@ public String computeSignature(String key, String data) { public byte[] computeHash(byte[] key, byte[] data) { return sign(key, data, macInstance, LOCK, ALGORITHM); } + + static { + try { + macInstance = Mac.getInstance(ALGORITHM); + } catch (Throwable e) { + } + } } \ No newline at end of file