mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -16,7 +16,7 @@ import java.security.SecureRandom;
|
||||
public class AESTest {
|
||||
|
||||
@Test
|
||||
public void encryptTest() {
|
||||
public void encryptCBCTest() {
|
||||
// 构建
|
||||
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding,
|
||||
"1234567890123456".getBytes(), "1234567890123456".getBytes());
|
||||
@@ -25,7 +25,7 @@ public class AESTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encryptTest2() {
|
||||
public void encryptCTSTest() {
|
||||
String content = "test中文";
|
||||
AES aes = new AES(Mode.CTS, Padding.PKCS5Padding,
|
||||
"0CoJUm6Qyw8W8jue".getBytes(), "0102030405060708".getBytes());
|
||||
|
@@ -14,11 +14,11 @@ import cn.hutool.crypto.symmetric.DESede;
|
||||
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
|
||||
import cn.hutool.crypto.symmetric.SymmetricCrypto;
|
||||
import cn.hutool.crypto.symmetric.Vigenere;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 对称加密算法单元测试
|
||||
@@ -109,6 +109,19 @@ public class SymmetricTest {
|
||||
Assert.assertEquals("cd0e3a249eaf0ed80c330338508898c4bddcfd665a1b414622164a273ca5daf7b4ebd2c00aaa66b84dd0a237708dac8e", encryptHex);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pbeWithoutIvTest() {
|
||||
String content = "4321c9a2db2e6b08987c3b903d8d11ff";
|
||||
SymmetricCrypto crypto = new SymmetricCrypto(SymmetricAlgorithm.PBEWithMD5AndDES,
|
||||
"0123456789ABHAEQ".getBytes());
|
||||
|
||||
// 加密为16进制表示
|
||||
String encryptHex = crypto.encryptHex(content);
|
||||
final String data = crypto.decryptStr(encryptHex);
|
||||
|
||||
Assert.assertEquals(content, data);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aesUpdateTest() {
|
||||
String content = "4321c9a2db2e6b08987c3b903d8d11ff";
|
||||
|
Reference in New Issue
Block a user