fix bug and add crypto

This commit is contained in:
Looly
2020-07-23 12:10:58 +08:00
parent 1e22cce3a3
commit b47125c9f1
7 changed files with 140 additions and 5 deletions

View File

@@ -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);
}
}

View File

@@ -196,5 +196,4 @@ public class RSATest {
final String encryptBase64 = rsa.encryptBase64("测试内容", KeyType.PublicKey);
Assert.assertNotNull(encryptBase64);
}
}