参考来源PHP代码
亲测15版本可以
该代码只写了参考中的12的情况(稍高版本)
- 示例参考
import cn.hutool.core.util.HexUtil;
import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.AES;
import org.junit.jupiter.api.Test;
public class DecodeTest {
@Test
public void decode() {
String aesKey = "libcckeylibcckey";
String aesIv = "libcciv libcciv ";
String str = "503AA930968F877F04770B47DD731DC0";
str = str.toLowerCase();
byte[] tmp = HexUtil.decodeHex(str);
AES aes = new AES(Mode.CBC, Padding.PKCS5Padding, aesKey.getBytes(), aesIv.getBytes());
String rs = aes.decryptStr(tmp);
System.out.println(rs);
}
}
- 测试结果
root
Process finished with exit code 0
- 依赖包引入 - Hutool真香
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.8</version>
</dependency>
PS:
- 11采用BF-ECB方式,对应mode为AES.ECB
- 12采用AES-128-CBC方式,对应mode为AES.CBC
网友评论