> 1); $key[] = ($tmp[1] << 6) | ($tmp[2] >> 2); $key[] = ($tmp[2] << 5) | ($tmp[3] >> 3); $key[] = ($tmp[3] << 4) | ($tmp[4] >> 4); $key[] = ($tmp[4] << 3) | ($tmp[5] >> 5); $key[] = ($tmp[5] << 2) | ($tmp[6] >> 6); $key[] = $tmp[6] << 1; $key0 = ""; foreach ($key as $k) { $key0 .= chr($k); } $crypt = openssl_encrypt("KGS!@#$%", "des-ecb", $key0 , OPENSSL_RAW_DATA + OPENSSL_ZERO_PADDING); return bin2hex($crypt); } static function lm(string $clear): string { $string = strtoupper(substr($clear,0,14)); $part1 = self::lm_des_encrypt(substr($string, 0, 7)); $part2 = self::lm_des_encrypt(substr($string, 7, 7)); return strtoupper($part1.$part2); } private static $lsc_key; static function init_lsc(string $key): void { self::$lsc_key = hex2bin($key); } private static function lsc_key(): string { $lsc_key = self::$lsc_key; if ($lsc_key === null) { throw IllegalAccessException::unexpected_state("init_lsc"); } return $lsc_key; } static function is_lsc_available(): bool { return self::$lsc_key !== null; } static function decrypt_lsc(string $lsc): string { return openssl_decrypt($lsc, "aes-128-ecb", self::lsc_key()); } static function encrypt_lsc(string $clear): string { return openssl_encrypt($clear, "aes-128-ecb", self::lsc_key()); } }