add ZeroPadding support

This commit is contained in:
Looly
2019-09-21 22:24:59 +08:00
parent 4292d3fd55
commit c9f77e1746
9 changed files with 362 additions and 161 deletions

View File

@@ -1,5 +1,8 @@
package cn.hutool.crypto.test;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.RandomUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -106,6 +109,18 @@ public class SymmetricTest {
Assert.assertEquals("cd0e3a249eaf0ed80c330338508898c4bddcfd665a1b414622164a273ca5daf7b4ebd2c00aaa66b84dd0a237708dac8e", encryptHex);
}
@Test
public void aesZeroPaddingTest() {
String content = RandomUtil.randomString(RandomUtil.randomInt(200));
AES aes = new AES(Mode.CBC, Padding.ZeroPadding, "0123456789ABHAEQ".getBytes(), "DYgjCEIMVrj2W9xN".getBytes());
// 加密为16进制表示
String encryptHex = aes.encryptHex(content);
// 解密
String decryptStr = aes.decryptStr(encryptHex);
Assert.assertEquals(content, decryptStr);
}
@Test
public void desTest() {
String content = "test中文";