mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
fix bug
This commit is contained in:
parent
04032f1094
commit
98512fa1f2
@ -25,6 +25,7 @@
|
||||
* 【cache 】 修复LRUCache线程安全问题(issue#1895@Github)
|
||||
* 【crypto 】 修复KeyUtil异常信息参数丢失问题(issue#1902@Github)
|
||||
* 【core 】 修复StrUtil.split和splittoArray不一致问题(issue#I4ELU5@Github)
|
||||
* 【core 】 修复SymmetricCrypto未关闭CipherOutputStream导致的问题(issue#I4EMST@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -201,13 +201,11 @@ If you think Hutool is good, you can donate to buy tshe author a pack of chili~,
|
||||
|
||||
## 👕shop
|
||||
|
||||
We provide the T-Shirt with Hutool Logo, please visit the shop:
|
||||
We provide the T-Shirt and Sweater with Hutool Logo, please visit the shop:
|
||||
|
||||
[Hutool T-Shirt](https://m.tb.cn/h.f47W8zc?sm=7d2b95)
|
||||
|
||||
<div align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/looly/hutool-site/images/t_shirt.jpg">
|
||||
</div>
|
||||
[Hutool Sweater](https://m.tb.cn/h.fUM4d6B?sm=4c0a5f)
|
||||
|
||||
## 📌WeChat Official Account
|
||||
|
||||
|
12
README.md
12
README.md
@ -202,21 +202,19 @@ Hutool欢迎任何人为Hutool添砖加瓦,贡献代码,不过维护者是
|
||||
|
||||
如果你觉得Hutool不错,可以捐赠请维护者吃包辣条~,在此表示感谢^_^。
|
||||
|
||||
点击以下链接,将页面拉到最下方点击“捐赠”即可。
|
||||
|
||||
[Gitee上捐赠](https://gitee.com/dromara/hutool)
|
||||
|
||||
[捐赠给Dromara组织](https://dromara.gitee.io/donate.html)
|
||||
|
||||
## 👕周边
|
||||
|
||||
我们提供了印有Hutool Logo的主题T恤,欢迎点击购买:
|
||||
你也可以通过购买Hutool的周边商品来支持Hutool维护哦!
|
||||
|
||||
[HutoolT恤商店](https://m.tb.cn/h.f47W8zc?sm=7d2b95)
|
||||
我们提供了印有Hutool Logo的周边商品,欢迎点击购买支持:
|
||||
|
||||
<div align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/looly/hutool-site/images/t_shirt.jpg">
|
||||
</div>
|
||||
[Hutool周边商店-T恤](https://m.tb.cn/h.f47W8zc?sm=7d2b95)
|
||||
|
||||
[Hutool周边商店-卫衣](https://m.tb.cn/h.fUM4d6B?sm=4c0a5f)
|
||||
|
||||
## 📌公众号
|
||||
|
||||
|
@ -299,7 +299,7 @@ public class Base64 {
|
||||
* base64解码
|
||||
*
|
||||
* @param base64 被解码的base64字符串
|
||||
* @return 被加密后的字符串
|
||||
* @return 解码后的bytes
|
||||
*/
|
||||
public static byte[] decode(CharSequence base64) {
|
||||
return Base64Decoder.decode(base64);
|
||||
|
@ -300,9 +300,11 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
throw new CryptoException(e);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
// issue#I4EMST@Gitee
|
||||
// CipherOutputStream必须关闭,才能完全写出
|
||||
IoUtil.close(cipherOutputStream);
|
||||
if (isClose) {
|
||||
IoUtil.close(data);
|
||||
IoUtil.close(cipherOutputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,9 +353,11 @@ public class SymmetricCrypto implements SymmetricEncryptor, SymmetricDecryptor,
|
||||
throw new CryptoException(e);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
// issue#I4EMST@Gitee
|
||||
// CipherOutputStream必须关闭,才能完全写出
|
||||
IoUtil.close(cipherInputStream);
|
||||
if (isClose) {
|
||||
IoUtil.close(data);
|
||||
IoUtil.close(cipherInputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,4 +81,6 @@ public class SmTest {
|
||||
String digest = hMac.digestHex(content);
|
||||
Assert.assertEquals("493e3f9a1896b43075fbe54658076727960d69632ac6b6ed932195857a6840c6", digest);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.crypto.symmetric.SM4;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* https://gitee.com/dromara/hutool/issues/I4EMST
|
||||
*/
|
||||
public class Sm4StreamTest {
|
||||
|
||||
private static final SM4 sm4 = new SM4();
|
||||
|
||||
private static final boolean IS_CLOSE = false;
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void sm4Test(){
|
||||
String source = "d:/test/sm4_1.txt";
|
||||
String target = "d:/test/sm4_2.data";
|
||||
String target2 = "d:/test/sm4_3.txt";
|
||||
encrypt(source, target);
|
||||
decrypt(target, target2);
|
||||
}
|
||||
|
||||
public static void encrypt(String source, String target) {
|
||||
try (InputStream input = new FileInputStream(source);
|
||||
OutputStream out = new FileOutputStream(target)) {
|
||||
sm4.encrypt(input, out, IS_CLOSE);
|
||||
System.out.println("============encrypt end");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void decrypt(String source, String target) {
|
||||
try (InputStream input = new FileInputStream(source);
|
||||
OutputStream out = new FileOutputStream(target)) {
|
||||
sm4.decrypt(input, out, IS_CLOSE);
|
||||
System.out.println("============decrypt end");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user