Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php class NavicatPassword { private $version = 0; private $aesKey = 'libcckeylibcckey'; private $aesIv = 'libcciv libcciv '; private $blowString = '3DC5CA39'; private $blowKey = null; private $blowIv = null; public function __construct($version = 12) { $this->version = $version; $this->blowKey = sha1('3DC5CA39', true); $this->blowIv = hex2bin('d9c7c3c8870d64bd'); } public function decrypt($string) { $result = FALSE; if ($this->version == 12) { $result = $this->decryptTwelve($string); } else { $result = $this->decryptEleven($string); } 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); } 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; } } // 填入你Navicat中的加密密码 $encryptedPassword = '1CC99E38FD27AE370628ABE46B90C424'; // 尝试Navicat 12版本解密 $navicatPassword = new NavicatPassword(12); $decode12 = $navicatPassword->decrypt($encryptedPassword); // 尝试Navicat 11版本解密 $navicatPassword = new NavicatPassword(11); $decode11 = $navicatPassword->decrypt($encryptedPassword); echo "尝试Navicat 12版本解密: ". $decode12."\n"; echo "尝试Navicat 11版本解密: ". $decode11."\n"; ?>
Copy Clear