public static function Crypt($str, $key = false) { if ($key === false) { $key = COption::GetOptionString("main", "pwdhashadd", "ldap"); } $key1 = CLdapUtil::BinMD5($key); while ($str) { if (function_exists('mb_substr')) { $m = mb_substr($str, 0, 16, "ASCII"); $str = mb_substr($str, 16, mb_strlen($str, "ASCII") - 16, "ASCII"); } else { $m = substr($str, 0, 16); $str = substr($str, 16); } $res .= CLdapUtil::ByteXOR($m, $key1, 16); $key1 = CLdapUtil::BinMD5($key . $key1 . $m); } return base64_encode($res); }