", "~", "+", "=", ",", "." )); } $charsLen = count($chars) - 1; shuffle($chars); $str = ''; for ($i = 0; $i < $len; $i++) { $str .= $chars[mt_rand(0, $charsLen)]; } return $str; } public static function buildVmessLink($item, $user) { $config = [ "v" => "2", "ps" => $item->name, "add" => $item->host, "port" => $item->port, "id" => $user->v2ray_uuid, "aid" => "2", "net" => $item->network, "type" => "none", "host" => "", "path" => "", "tls" => $item->tls ? "tls" : "" ]; if ($item->network == 'ws') { $wsSettings = json_decode($item->settings); if (isset($wsSettings->path)) $config['path'] = $wsSettings->path; if (isset($wsSettings->headers->Host)) $config['host'] = $wsSettings->headers->Host; } return "vmess://" . base64_encode(json_encode($config)) . "\r\n"; } public static function multiPasswordVerify($algo, $password, $hash) { switch($algo) { case 'md5': return md5($password) === $hash; case 'sha256': return hash('sha256', $password) === $hash; default: return password_verify($password, $hash); } } }