updated BITMESSAGE_SIZE_LIMIT

added EncodeBase64/DecodeBase64 to Utils::String
This commit is contained in:
/dev/root 2016-08-27 23:46:24 +02:00
parent bd7faf2b32
commit a82aab26fa
3 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,6 @@
#define UPLOAD_URL "https://reich.io/upload.php"
#define BITMESSAGE_UPLOAD_IDENTITY "BM-NBhqCHraxGyUT38cfhRQYWx29gJ7QePa"
#define BITMESSAGE_SIZE_LIMIT 25600
#define BITMESSAGE_SIZE_LIMIT 230000
namespace Components
{

View File

@ -117,7 +117,7 @@ namespace Utils
}
// Encodes a given string in Base64
std::string encodeBase64(const char* input, const unsigned long inputSize) {
std::string EncodeBase64(const char* input, const unsigned long inputSize) {
unsigned long outlen = long(inputSize + (inputSize / 3.0) + 16);
unsigned char* outbuf = new unsigned char[outlen]; //Reserve output memory
base64_encode((unsigned char*)input, inputSize, outbuf, &outlen);
@ -127,8 +127,18 @@ namespace Utils
}
// Encodes a given string in Base64
std::string encodeBase64(const std::string& input) {
return encodeBase64(input.c_str(), input.size());
std::string EncodeBase64(const std::string& input) {
return EncodeBase64(input.c_str(), input.size());
}
// Decodes a given string from Base64
std::string DecodeBase64(const std::string& input) {
unsigned char* out = new unsigned char[input.size()];
unsigned long outlen = input.size();
base64_decode((unsigned char*)input.c_str(), input.size(), out, &outlen);
std::string ret((char*)out, outlen);
delete[] out;
return ret;
}
}
}

View File

@ -40,7 +40,8 @@ namespace Utils
std::string XOR(std::string str, char value);
std::string encodeBase64(const char* input, const unsigned long inputSize);
std::string encodeBase64(const std::string& input);
std::string EncodeBase64(const char* input, const unsigned long inputSize);
std::string EncodeBase64(const std::string& input);
std::string DecodeBase64(const std::string& input);
}
}