@ 2025-01-03T03:13:21Z <?php
class NavicatPassword
{
protected $version = 0;
protected $aesKey = 'libcckeylibcckey';
protected $aesIv = 'libcciv libcciv ';
protected $blowString = '3DC5CA39';
protected $blowKey = null;
protected $blowIv = null;
public function __construct($version = 12)
{
$this->version = $version;
$this->blowKey = sha1('3DC5CA39', true);
$this->blowIv = hex2bin('d9c7c3c8870d64bd');
}
public function encrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->encryptEleven($string);
break;
case 12:
$result = $this->encryptTwelve($string);
break;
default:
break;
}
return $result;
}
protected function encryptEleven($string)
{
$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;
for ($i = 0; $i < $round; $i++) {
$temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
$currentVector = $this->xorBytes($currentVector, $temp);
$result .= $temp;
}
if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}
return strtoupper(bin2hex($result));
}
protected function encryptBlock($block)
{
return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}
protected function decryptBlock($block)
{
return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}
protected function xorBytes($str1, $str2)
{
$result = '';
for ($i = 0; $i < strlen($str1); $i++) {
$result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
}
return $result;
}
protected function encryptTwelve($string)
{
$result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
return strtoupper(bin2hex($result));
}
public function decrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->decryptEleven($string);
break;
case 12:
$result = $this->decryptTwelve($string);
break;
default:
break;
}
return $result;
}
protected function decryptEleven($upperString)
{
$string = hex2bin(strtolower($upperString));
$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;
for ($i = 0; $i < $round; $i++) {
$encryptedBlock = substr($string, 8 * $i, 8);
$temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
$currentVector = $this->xorBytes($currentVector, $encryptedBlock);
$result .= $temp;
}
if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}
return $result;
}
protected function decryptTwelve($upperString)
{
$string = hex2bin(strtolower($upperString));
return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
}
};
//需要指定navacat版本两种,11或12
$navicatPassword = new NavicatPassword(12);
//解密,括号里面写入navicat加密后的密码
$decode = $navicatPassword->decrypt('4137021BF94FD1A8E352B5F967A370A2');
echo $decode."\n";
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.2 0.034 0.015 17.81 8.4.1 0.034 0.013 17.73 8.3.16 0.009 0.009 16.72 8.3.15 0.033 0.010 16.56 8.3.14 0.036 0.011 16.66 8.3.13 0.035 0.007 16.45 8.3.12 0.036 0.008 16.77 8.3.11 0.029 0.013 16.66 8.3.10 0.046 0.009 16.66 8.3.9 0.038 0.008 16.73 8.3.8 0.040 0.003 16.71 8.3.7 0.024 0.009 16.72 8.3.6 0.031 0.002 16.68 8.3.5 0.025 0.010 16.74 8.3.4 0.034 0.008 17.59 8.3.3 0.032 0.008 17.53 8.3.2 0.031 0.007 17.55 8.3.1 0.031 0.005 17.58 8.3.0 0.015 0.006 17.78 8.2.27 0.021 0.009 16.54 8.2.26 0.026 0.008 16.45 8.2.25 0.029 0.009 16.51 8.2.24 0.028 0.010 16.55 8.2.23 0.030 0.009 16.41 8.2.22 0.029 0.009 16.55 8.2.21 0.029 0.010 16.62 8.2.20 0.031 0.009 16.57 8.2.19 0.026 0.013 16.34 8.2.18 0.028 0.012 16.63 8.2.17 0.032 0.009 17.65 8.2.16 0.029 0.005 17.77 8.2.15 0.025 0.008 17.39 8.2.14 0.035 0.007 17.47 8.2.13 0.036 0.005 17.54 8.2.12 0.027 0.014 17.50 8.2.11 0.036 0.007 17.47 8.2.10 0.030 0.010 17.46 8.2.9 0.036 0.006 17.59 8.2.8 0.031 0.008 17.47 8.2.7 0.033 0.008 17.46 8.2.6 0.024 0.008 17.48 8.2.5 0.028 0.012 17.30 8.2.4 0.026 0.009 17.39 8.2.3 0.029 0.010 17.42 8.2.2 0.033 0.008 17.41 8.2.1 0.030 0.005 17.40 8.2.0 0.028 0.009 17.40
preferences:dark mode live preview
18.78 ms | 403 KiB | 5 Q