mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add method
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
package cn.hutool.crypto.test.asymmetric;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.asymmetric.Sign;
|
||||
import cn.hutool.crypto.asymmetric.SignAlgorithm;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@@ -2,12 +2,17 @@ package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.crypto.KeyUtil;
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
public class AESTest {
|
||||
|
||||
@Test
|
||||
@@ -95,4 +100,17 @@ public class AESTest {
|
||||
Assert.assertEquals("16c5", aes.decryptStr(Base64.decode("ecIQ0+MEkyz56mqciHxtfA==")));
|
||||
// ------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aesWithSha1PrngTest() {
|
||||
final SecureRandom random = RandomUtil.getSecureRandom("123456".getBytes());
|
||||
final SecretKey secretKey = KeyUtil.generateKey("AES", 128, random);
|
||||
|
||||
String content = "12sdfsdfs你好啊!";
|
||||
AES aes = new AES(secretKey);
|
||||
final String result1 = aes.encryptBase64(content);
|
||||
|
||||
final String decryptStr = aes.decryptStr(result1);
|
||||
Assert.assertEquals(content, decryptStr);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user