mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2026-11-02 01:33:04 +00:00
Enhancements
Add support for exporting SIP002 subscription. Add support for exporting ShadowsocksR subscription. Add support for exporting ShadowsocksD subscription. Add support for exporting v2rayN ver.2 VMess subscription. Add support for exporting Quantumult VMess subscription. Add support for exporting Quantumult X subscription. TODO: Clean up duplicate codes.
This commit is contained in:
5 files changed
+487
-6
No files matched your search
@@ -104,6 +104,11 @@ void StringToWstring(std::wstring& szDst, std::string str)
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
unsigned char ToHex(unsigned char x)
|
||||
{
|
||||
return x > 9 ? x + 55 : x + 48;
|
||||
}
|
||||
|
||||
unsigned char FromHex(unsigned char x)
|
||||
{
|
||||
unsigned char y = '\0';
|
||||
@@ -118,6 +123,30 @@ unsigned char FromHex(unsigned char x)
|
||||
return y;
|
||||
}
|
||||
|
||||
std::string UrlEncode(const std::string& str)
|
||||
{
|
||||
std::string strTemp = "";
|
||||
size_t length = str.length();
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (isalnum((unsigned char)str[i]) ||
|
||||
(str[i] == '-') ||
|
||||
(str[i] == '_') ||
|
||||
(str[i] == '.') ||
|
||||
(str[i] == '~'))
|
||||
strTemp += str[i];
|
||||
else if (str[i] == ' ')
|
||||
strTemp += "+";
|
||||
else
|
||||
{
|
||||
strTemp += '%';
|
||||
strTemp += ToHex((unsigned char)str[i] >> 4);
|
||||
strTemp += ToHex((unsigned char)str[i] % 16);
|
||||
}
|
||||
}
|
||||
return strTemp;
|
||||
}
|
||||
|
||||
std::string UrlDecode(const std::string& str)
|
||||
{
|
||||
std::string strTemp = "";
|
||||
@@ -447,6 +476,11 @@ std::string urlsafe_base64_decode(std::string encoded_string)
|
||||
return base64_decode(urlsafe_base64_reverse(encoded_string));
|
||||
}
|
||||
|
||||
std::string urlsafe_base64_encode(std::string string_to_encode)
|
||||
{
|
||||
return replace_all_distinct(replace_all_distinct(base64_encode(string_to_encode), "+", "-"), "/", "_");
|
||||
}
|
||||
|
||||
std::string getMD5(std::string data)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
|
||||
Reference in new issue
Block a user