This repository has been archived by the owner on Jul 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attachments are now held in script object scope
* this matches CouchDB behaviour * still needs units and HEAD/DELETE
- Loading branch information
1 parent
9f197da
commit a263113
Showing
29 changed files
with
647 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule ConstTimeEncoding
added at
faeff4
Submodule libscriptobject
updated
24 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* AvanceDB - an in-memory database similar to Apache CouchDB | ||
* Copyright (C) 2015 Ripcord Software | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "base64_helper.h" | ||
|
||
#include <algorithm> | ||
|
||
#include "../../externals/ConstTimeEncoding/base64.h" | ||
|
||
std::string Base64Helper::Encode(const std::vector<unsigned char>& data) { | ||
auto encodedSize = data.size() * 4; | ||
encodedSize = (encodedSize + 3) / 3; | ||
encodedSize += 4 - (encodedSize % 4); | ||
|
||
std::string text; | ||
text.resize(encodedSize); | ||
|
||
base64Encode(&text[0], data.data(), data.size()); | ||
|
||
return text; | ||
} | ||
|
||
std::vector<unsigned char> Base64Helper::Decode(const char* text, std::size_t size) { | ||
std::vector<unsigned char> data; | ||
|
||
if (size > 0) { | ||
auto decodedSize = size; | ||
while (text[decodedSize - 1] == '=') { | ||
--decodedSize; | ||
} | ||
|
||
decodedSize *= 3; | ||
decodedSize /= 4; | ||
data.resize(decodedSize); | ||
|
||
base64Decode(data.data(), text, size); | ||
} | ||
|
||
return data; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* AvanceDB - an in-memory database similar to Apache CouchDB | ||
* Copyright (C) 2015 Ripcord Software | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef BASE64_HELPER_H | ||
#define BASE64_HELPER_H | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
class Base64Helper final { | ||
public: | ||
Base64Helper() = delete; | ||
|
||
static std::string Encode(const std::vector<unsigned char>& data); | ||
static std::vector<unsigned char> Decode(const char* text, std::size_t size); | ||
|
||
private: | ||
|
||
}; | ||
|
||
#endif /* BASE64_HELPER_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.