', '~', '+', '=', ',', '.' )); } $charsLen = count($chars) - 1; shuffle($chars); $password = ''; for($i=0; $i<$length; $i++){ $password .= $chars[mt_rand(0, $charsLen)]; } return $password; } public static function encrypt(string $data) { $iv = '62dTsnuD1Ow68pR8'; return openssl_encrypt($data, self::CIPHER_ALGO, self::PASSPHRASE, 0, $iv); } public static function decrypt(string $password) { $iv = '62dTsnuD1Ow68pR8'; return openssl_decrypt($password, self::CIPHER_ALGO, self::PASSPHRASE, 0, $iv); } public static function parseUrl(string $url) { if (empty($url)) { return $url; } $item = explode(':', $url); if (!isset($item[0]) || in_array($item[0], ['http', 'https'])) { return $url; } return self::getFileUrlViaStorage($item[1], $item[0]); } public static function getFileUrlViaStorage(string $url, string $storage): string { $domain = config('file.storage.' . $storage . '.domain'); $prefixPath = config('file.storage.' . $storage . '.prefix_path', ''); return $domain . $prefixPath . $url; } }