mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix bug and add crypto
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package cn.hutool.crypto.test;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.ECIES;
|
||||
import cn.hutool.crypto.asymmetric.KeyType;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ECIESTest {
|
||||
|
||||
@Test
|
||||
public void eciesTest(){
|
||||
final ECIES ecies = new ECIES();
|
||||
|
||||
String textBase = "我是一段特别长的测试";
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
text.append(textBase);
|
||||
}
|
||||
|
||||
// 公钥加密,私钥解密
|
||||
String encryptStr = ecies.encryptBase64(text.toString(), KeyType.PublicKey);
|
||||
String decryptStr = StrUtil.utf8Str(ecies.decrypt(encryptStr, KeyType.PrivateKey));
|
||||
Assert.assertEquals(text.toString(), decryptStr);
|
||||
}
|
||||
}
|
@@ -196,5 +196,4 @@ public class RSATest {
|
||||
final String encryptBase64 = rsa.encryptBase64("测试内容", KeyType.PublicKey);
|
||||
Assert.assertNotNull(encryptBase64);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user