package com.test;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;
public class NavicatPassword {
private int version = 0;
private static final String AES_KEY = "libcckeylibcckey";
private static final String AES_IV = "libcciv libcciv ";
private final byte[] blowKey;
private final byte[] blowIv;
public NavicatPassword(int version) {
this.version = version;
this.blowKey = sha1("3DC5CA39".getBytes());
this.blowIv = hexStringToByteArray("d9c7c3c8870d64bd");
}
public String encrypt(String input) throws Exception {
String result = null;
switch (version) {
case 11:
result = encryptEleven(input);
break;
case 12:
result = encryptTwelve(input);
break;
default:
throw new IllegalArgumentException("Unsupported version");
}
return result;
}
private String encryptEleven(String input) throws Exception {
int round = input.length() / 8;
int leftLength = input.length() % 8;
StringBuilder result = new StringBuilder();
byte[] currentVector = blowIv
解密navicat密码(java版本)
于 2025-02-14 17:08:43 首次发布