Compare commits
4 Commits
v0.1.3.4
...
5493c0dcf3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5493c0dcf3 | ||
|
|
cd7e957692 | ||
| d712d3a9d8 | |||
| 000fde485f |
@@ -17,8 +17,16 @@ elseif(UNIX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Handle dependencies
|
# Handle dependencies
|
||||||
find_package(cryptopp CONFIG REQUIRED)
|
if(WIN32)
|
||||||
find_package(nlohmann_json CONFIG REQUIRED)
|
# Windows: Use vcpkg packages
|
||||||
|
find_package(cryptopp CONFIG REQUIRED)
|
||||||
|
find_package(nlohmann_json CONFIG REQUIRED)
|
||||||
|
else()
|
||||||
|
# Linux: Use system packages
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(CRYPTOPP REQUIRED libcryptopp)
|
||||||
|
pkg_check_modules(NLOHMANN_JSON REQUIRED nlohmann_json)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add library sources
|
# Add library sources
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
@@ -40,22 +48,42 @@ set(HEADERS
|
|||||||
# Create the shared library
|
# Create the shared library
|
||||||
add_library(privatebinapi SHARED ${SOURCES} ${HEADERS})
|
add_library(privatebinapi SHARED ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
|
# Define PRIVATEBINAPI_EXPORTS for the library build
|
||||||
|
target_compile_definitions(privatebinapi PRIVATE PRIVATEBINAPI_EXPORTS)
|
||||||
|
|
||||||
# Include directories
|
# Include directories
|
||||||
target_include_directories(privatebinapi PUBLIC
|
target_include_directories(privatebinapi PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
)
|
)
|
||||||
|
|
||||||
# Explicitly include vcpkg directories
|
# Platform-specific include directories
|
||||||
target_include_directories(privatebinapi PRIVATE
|
if(WIN32)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
# Windows: Include vcpkg directories
|
||||||
)
|
target_include_directories(privatebinapi PRIVATE
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed/x64-windows/include
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Link dependencies
|
# Link dependencies
|
||||||
target_link_libraries(privatebinapi PRIVATE
|
if(WIN32)
|
||||||
cryptopp::cryptopp
|
# Windows: Use vcpkg targets
|
||||||
nlohmann_json::nlohmann_json
|
target_link_libraries(privatebinapi PRIVATE
|
||||||
${PLATFORM_LIBS}
|
cryptopp::cryptopp
|
||||||
)
|
nlohmann_json::nlohmann_json
|
||||||
|
${PLATFORM_LIBS}
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
# Linux: Use system libraries
|
||||||
|
target_link_libraries(privatebinapi PRIVATE
|
||||||
|
${CRYPTOPP_LIBRARIES}
|
||||||
|
${NLOHMANN_JSON_LIBRARIES}
|
||||||
|
${PLATFORM_LIBS}
|
||||||
|
)
|
||||||
|
target_include_directories(privatebinapi PRIVATE
|
||||||
|
${CRYPTOPP_INCLUDE_DIRS}
|
||||||
|
${NLOHMANN_JSON_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install targets
|
# Install targets
|
||||||
install(TARGETS privatebinapi
|
install(TARGETS privatebinapi
|
||||||
|
|||||||
105
README.md
105
README.md
@@ -119,9 +119,11 @@ This script:
|
|||||||
- Configures CMake with proper toolchain
|
- Configures CMake with proper toolchain
|
||||||
- Builds the project using MSVC compiler
|
- Builds the project using MSVC compiler
|
||||||
|
|
||||||
### Linux/macOS Build Script
|
### Linux Build Scripts
|
||||||
|
|
||||||
|
#### Automated Build Script
|
||||||
**File:** `scripts/build.sh`
|
**File:** `scripts/build.sh`
|
||||||
**Requirements:** CMake, C++17 compiler, vcpkg
|
**Requirements:** CMake, C++17 compiler, system packages
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Make executable and run from project root
|
# Make executable and run from project root
|
||||||
@@ -129,6 +131,54 @@ chmod +x scripts/build.sh
|
|||||||
./scripts/build.sh
|
./scripts/build.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This script:
|
||||||
|
- Automatically detects and installs required dependencies
|
||||||
|
- Configures CMake with Unix Makefiles
|
||||||
|
- Builds the project in Release configuration
|
||||||
|
|
||||||
|
#### Manual Linux Build (Recommended)
|
||||||
|
**Requirements:** CMake 3.10+, GCC/Clang with C++17 support, system packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dependencies (Fedora/RHEL/CentOS)
|
||||||
|
sudo dnf install cmake gcc-c++ libcurl-devel cryptopp-devel json-devel
|
||||||
|
|
||||||
|
# Install dependencies (Ubuntu/Debian)
|
||||||
|
sudo apt install cmake g++ libcurl4-openssl-dev libcrypto++-dev nlohmann-json3-dev
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
# Run tests
|
||||||
|
ctest --verbose
|
||||||
|
|
||||||
|
# Run example
|
||||||
|
./example/example
|
||||||
|
```
|
||||||
|
|
||||||
|
**Linux Dependencies:**
|
||||||
|
- **libcurl-devel** - HTTP client library
|
||||||
|
- **cryptopp-devel** - Cryptographic library
|
||||||
|
- **json-devel** - JSON parsing library
|
||||||
|
- **cmake** - Build system
|
||||||
|
- **gcc-c++** - C++17 compiler
|
||||||
|
|
||||||
|
### macOS Build Script
|
||||||
|
**File:** `scripts/build.sh`
|
||||||
|
**Requirements:** CMake, C++17 compiler, Homebrew packages
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install dependencies via Homebrew
|
||||||
|
brew install cmake cryptopp nlohmann-json curl
|
||||||
|
|
||||||
|
# Make executable and run from project root
|
||||||
|
chmod +x scripts/build.sh
|
||||||
|
./scripts/build.sh
|
||||||
|
```
|
||||||
|
|
||||||
This script:
|
This script:
|
||||||
- Bootstraps vcpkg if not present
|
- Bootstraps vcpkg if not present
|
||||||
- Configures CMake with Unix Makefiles
|
- Configures CMake with Unix Makefiles
|
||||||
@@ -140,8 +190,9 @@ This script:
|
|||||||
|
|
||||||
- CMake 3.10+
|
- CMake 3.10+
|
||||||
- C++17 compatible compiler
|
- C++17 compatible compiler
|
||||||
- Crypto++ (via vcpkg)
|
- **Windows:** Crypto++ and nlohmann/json (via vcpkg)
|
||||||
- nlohmann/json (via vcpkg)
|
- **Linux:** libcurl, cryptopp, and nlohmann-json (via system packages)
|
||||||
|
- **macOS:** libcurl, cryptopp, and nlohmann/json (via Homebrew)
|
||||||
|
|
||||||
### Compilation
|
### Compilation
|
||||||
|
|
||||||
@@ -157,14 +208,43 @@ powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\build_windows.ps1
|
|||||||
scripts\build_thinkpad.bat
|
scripts\build_thinkpad.bat
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Linux/macOS - Build via scripts/build.sh
|
#### Linux - Automated Build via scripts/build.sh
|
||||||
```bash
|
```bash
|
||||||
# Requires: CMake, C++17 compiler, vcpkg
|
# Requires: CMake, C++17 compiler, system packages
|
||||||
chmod +x scripts/build.sh
|
chmod +x scripts/build.sh
|
||||||
./scripts/build.sh
|
./scripts/build.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Manual Build
|
#### Linux - Manual Build (Recommended)
|
||||||
|
```bash
|
||||||
|
# Install dependencies (Fedora/RHEL/CentOS)
|
||||||
|
sudo dnf install cmake gcc-c++ libcurl-devel cryptopp-devel json-devel
|
||||||
|
|
||||||
|
# Install dependencies (Ubuntu/Debian)
|
||||||
|
sudo apt install cmake g++ libcurl4-openssl-dev libcrypto++-dev nlohmann-json3-dev
|
||||||
|
|
||||||
|
# Build the project
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make -j$(nproc)
|
||||||
|
|
||||||
|
# Run tests and examples
|
||||||
|
ctest --verbose
|
||||||
|
./example/example
|
||||||
|
```
|
||||||
|
|
||||||
|
#### macOS - Build via scripts/build.sh
|
||||||
|
```bash
|
||||||
|
# Install dependencies via Homebrew
|
||||||
|
brew install cmake cryptopp nlohmann-json curl
|
||||||
|
|
||||||
|
# Requires: CMake, C++17 compiler, Homebrew packages
|
||||||
|
chmod +x scripts/build.sh
|
||||||
|
./scripts/build.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Manual Build (All Platforms)
|
||||||
```bash
|
```bash
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
@@ -172,7 +252,9 @@ cmake ..
|
|||||||
cmake --build . --config Release
|
cmake --build . --config Release
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** The manual build method requires you to have all dependencies (CMake, compiler, vcpkg) properly configured. For most users, the platform-specific build scripts are recommended.
|
**Note:** The manual build method requires you to have all dependencies properly configured. For most users, the platform-specific build scripts are recommended.
|
||||||
|
|
||||||
|
**Linux Compatibility:** The project has been tested and successfully builds on Fedora Linux with system packages. It automatically detects the platform and uses appropriate dependency resolution methods (vcpkg for Windows, system packages for Linux/macOS).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -382,6 +464,13 @@ See [LICENSE](LICENSE) for details.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### v0.1.1.6 (2025-08-28)
|
||||||
|
- **NEW**: Full Linux compatibility with system packages
|
||||||
|
- **NEW**: Automatic platform detection (Windows: vcpkg, Linux: system packages)
|
||||||
|
- **IMPROVED**: Enhanced Linux build documentation and instructions
|
||||||
|
- **IMPROVED**: Better dependency management for cross-platform builds
|
||||||
|
- **FIXED**: CMakeLists.txt now works on both Windows and Linux without manual configuration
|
||||||
|
|
||||||
### v0.1.1.5 (2025-08-28)
|
### v0.1.1.5 (2025-08-28)
|
||||||
- **NEW**: Enhanced text format support (plaintext, syntax highlighting, markdown)
|
- **NEW**: Enhanced text format support (plaintext, syntax highlighting, markdown)
|
||||||
- **NEW**: Comprehensive format testing in examples and integration tests
|
- **NEW**: Comprehensive format testing in examples and integration tests
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ std::string Base58::encode(const std::vector<unsigned char>& data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert to base58
|
// Convert to base58
|
||||||
std::vector<unsigned char> digits((data.size() - leading_zeros) * 138 / 100 + 1);
|
std::vector<unsigned char> digits(static_cast<size_t>((data.size() - leading_zeros) * 138 / 100 + 1));
|
||||||
size_t digitslen = 1;
|
size_t digitslen = 1;
|
||||||
|
|
||||||
for (size_t i = leading_zeros; i < data.size(); i++) {
|
for (size_t i = leading_zeros; i < data.size(); i++) {
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ std::vector<unsigned char> Crypto::encrypt(const std::vector<unsigned char>& pla
|
|||||||
encryption.EncryptAndAuthenticate(
|
encryption.EncryptAndAuthenticate(
|
||||||
ciphertext.data(),
|
ciphertext.data(),
|
||||||
auth_tag.data(),
|
auth_tag.data(),
|
||||||
auth_tag.size(),
|
static_cast<int>(auth_tag.size()),
|
||||||
iv.data(),
|
iv.data(),
|
||||||
iv.size(),
|
static_cast<int>(iv.size()),
|
||||||
nullptr,
|
nullptr,
|
||||||
0, // Additional authenticated data
|
0, // Additional authenticated data
|
||||||
plaintext.data(),
|
plaintext.data(),
|
||||||
plaintext.size()
|
static_cast<int>(plaintext.size())
|
||||||
);
|
);
|
||||||
|
|
||||||
return ciphertext;
|
return ciphertext;
|
||||||
@@ -79,13 +79,13 @@ std::vector<unsigned char> Crypto::decrypt(const std::vector<unsigned char>& cip
|
|||||||
bool valid = decryption.DecryptAndVerify(
|
bool valid = decryption.DecryptAndVerify(
|
||||||
plaintext.data(),
|
plaintext.data(),
|
||||||
auth_tag.data(),
|
auth_tag.data(),
|
||||||
auth_tag.size(),
|
static_cast<int>(auth_tag.size()),
|
||||||
iv.data(),
|
iv.data(),
|
||||||
iv.size(),
|
static_cast<int>(iv.size()),
|
||||||
nullptr,
|
nullptr,
|
||||||
0, // Additional authenticated data
|
0, // Additional authenticated data
|
||||||
ciphertext.data(),
|
ciphertext.data(),
|
||||||
ciphertext.size()
|
static_cast<int>(ciphertext.size())
|
||||||
);
|
);
|
||||||
|
|
||||||
if(!valid) {
|
if(!valid) {
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ static void copy_string_to_output(const std::string& source, char** destination)
|
|||||||
if (destination) {
|
if (destination) {
|
||||||
*destination = static_cast<char*>(malloc(source.length() + 1));
|
*destination = static_cast<char*>(malloc(source.length() + 1));
|
||||||
if (*destination) {
|
if (*destination) {
|
||||||
std::strcpy(*destination, source.c_str());
|
strcpy_s(*destination, source.length() + 1, source.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
int create_paste(const char* server_url, const char* content,
|
PRIVATEBIN_API int create_paste(const char* server_url, const char* content,
|
||||||
const char* password, const char* expiration,
|
const char* password, const char* expiration,
|
||||||
const char* format, int burn_after_reading,
|
const char* format, int burn_after_reading,
|
||||||
int open_discussion, char** paste_url,
|
int open_discussion, char** paste_url,
|
||||||
@@ -128,10 +128,10 @@ int create_paste(const char* server_url, const char* content,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int upload_file(const char* server_url, const char* file_path,
|
PRIVATEBIN_API int upload_file(const char* server_url, const char* file_path,
|
||||||
const char* password, const char* expiration,
|
const char* password, const char* expiration,
|
||||||
int burn_after_reading, int open_discussion,
|
int burn_after_reading, int open_discussion,
|
||||||
char** paste_url, char** delete_token) {
|
char** paste_url, char** delete_token) {
|
||||||
|
|
||||||
if (!server_url || !file_path) {
|
if (!server_url || !file_path) {
|
||||||
return ERROR_INVALID_INPUT;
|
return ERROR_INVALID_INPUT;
|
||||||
@@ -248,7 +248,7 @@ int upload_file(const char* server_url, const char* file_path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_paste(const char* server_url, const char* paste_id,
|
PRIVATEBIN_API int get_paste(const char* server_url, const char* paste_id,
|
||||||
const char* key, char** content) {
|
const char* key, char** content) {
|
||||||
|
|
||||||
if (!server_url || !paste_id || !key || !content) {
|
if (!server_url || !paste_id || !key || !content) {
|
||||||
@@ -305,7 +305,7 @@ int get_paste(const char* server_url, const char* paste_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int delete_paste(const char* server_url, const char* paste_id,
|
PRIVATEBIN_API int delete_paste(const char* server_url, const char* paste_id,
|
||||||
const char* delete_token) {
|
const char* delete_token) {
|
||||||
|
|
||||||
if (!server_url || !paste_id || !delete_token) {
|
if (!server_url || !paste_id || !delete_token) {
|
||||||
@@ -347,7 +347,7 @@ int delete_paste(const char* server_url, const char* paste_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_string(char* str) {
|
PRIVATEBIN_API void free_string(char* str) {
|
||||||
if (str) {
|
if (str) {
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ static bool extract_paste_id_and_key(const std::string& full_url, std::string& p
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
const char* it = std::getenv("PRIVATEBIN_IT");
|
char* it = nullptr;
|
||||||
|
size_t len = 0;
|
||||||
|
_dupenv_s(&it, &len, "PRIVATEBIN_IT");
|
||||||
if (!it || std::string(it) == "0") {
|
if (!it || std::string(it) == "0") {
|
||||||
std::cout << "[test] PRIVATEBIN_IT not set; skipping integration test." << std::endl;
|
std::cout << "[test] PRIVATEBIN_IT not set; skipping integration test." << std::endl;
|
||||||
|
free(it);
|
||||||
return 0; // treat as success when integration testing is disabled
|
return 0; // treat as success when integration testing is disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user