This commit is contained in:
Looly 2021-09-08 11:16:30 +08:00
parent 8ddf18fb7a
commit 185fb1a72e

View File

@ -4,6 +4,7 @@ import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.CipherMode;
import cn.hutool.crypto.KeyUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
@ -128,7 +129,9 @@ public class SymmetricTest {
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, "0123456789ABHAEQ".getBytes(), "DYgjCEIMVrj2W9xN".getBytes());
// 加密为16进制表示
aes.setMode(CipherMode.encrypt);
String randomData = aes.updateHex(content.getBytes(StandardCharsets.UTF_8));
aes.setMode(CipherMode.encrypt);
String randomData2 = aes.updateHex(content.getBytes(StandardCharsets.UTF_8));
Assert.assertEquals(randomData2, randomData);
Assert.assertEquals(randomData, "cd0e3a249eaf0ed80c330338508898c4");