Navicat密码解密 java

2021-11-25  本文已影响0人  Ruining101

参考来源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
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.3.8</version>
        </dependency>

PS:

  1. 11采用BF-ECB方式,对应modeAES.ECB
  2. 12采用AES-128-CBC方式,对应modeAES.CBC
上一篇下一篇

猜你喜欢

热点阅读