public static function base64Encode($data, $url = false)
    {
        if ($url) {
            return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
        } else {
            return base64_encode($data);
        }
    }