Initial commit: PrivateBin API C++ DLL implementation
This commit is contained in:
127
README.md
Normal file
127
README.md
Normal file
@ -0,0 +1,127 @@
|
||||
# PrivateBin API C++ DLL
|
||||
|
||||
A cross-platform C++ library for interacting with PrivateBin servers.
|
||||
|
||||
## Overview
|
||||
|
||||
This library provides a simple C++ interface for interacting with PrivateBin services. PrivateBin is a minimalist, open-source online pastebin where the server has zero knowledge of stored data. All data is encrypted and decrypted in the browser using 256-bit AES encryption.
|
||||
|
||||
## Features
|
||||
|
||||
- Create new pastes with optional expiration, formatting, and security settings
|
||||
- Retrieve existing pastes by ID
|
||||
- Delete pastes using the deletion token
|
||||
- Cross-platform compatibility (Windows and Linux)
|
||||
- Support for PrivateBin API versions 1.3 and later
|
||||
|
||||
## Building
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- CMake 3.10 or later
|
||||
- C++17 compatible compiler
|
||||
- For Windows: Windows SDK
|
||||
- For Linux: libcurl development headers
|
||||
|
||||
### Dependencies
|
||||
|
||||
The library depends on the following components:
|
||||
|
||||
1. **HTTP Client**:
|
||||
- Windows: WinHTTP
|
||||
- Linux: libcurl
|
||||
|
||||
2. **JSON Processing**:
|
||||
- nlohmann/json
|
||||
|
||||
### Building on Windows
|
||||
|
||||
```cmd
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
### Building on Linux
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### API Functions
|
||||
|
||||
```cpp
|
||||
// Create a new paste
|
||||
int create_paste(const char* server_url, const char* content,
|
||||
const char* password, const char* expiration,
|
||||
const char* format, int burn_after_reading,
|
||||
int open_discussion, char** paste_url,
|
||||
char** delete_token);
|
||||
|
||||
// Retrieve a paste
|
||||
int get_paste(const char* server_url, const char* paste_id,
|
||||
const char* key, char** content);
|
||||
|
||||
// Delete a paste
|
||||
int delete_paste(const char* server_url, const char* paste_id,
|
||||
const char* delete_token);
|
||||
|
||||
// Free memory allocated by the API functions
|
||||
void free_string(char* str);
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```cpp
|
||||
#include "privatebinapi.h"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
char* paste_url = nullptr;
|
||||
char* delete_token = nullptr;
|
||||
|
||||
int result = create_paste(
|
||||
"https://privatebin.net",
|
||||
"Hello, PrivateBin!",
|
||||
nullptr, // No password
|
||||
"1hour", // Expire in 1 hour
|
||||
"plaintext", // Plain text format
|
||||
0, // Don't burn after reading
|
||||
0, // No discussion
|
||||
&paste_url,
|
||||
&delete_token
|
||||
);
|
||||
|
||||
if (result == 0) {
|
||||
std::cout << "Paste created: " << paste_url << std::endl;
|
||||
std::cout << "Delete token: " << delete_token << std::endl;
|
||||
|
||||
// Free allocated memory
|
||||
free_string(paste_url);
|
||||
free_string(delete_token);
|
||||
} else {
|
||||
std::cout << "Failed to create paste: " << result << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## Error Codes
|
||||
|
||||
- 0: Success
|
||||
- 1: Network error
|
||||
- 2: Encryption/decryption error
|
||||
- 3: Invalid input
|
||||
- 4: Server error
|
||||
- 5: JSON parsing error
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the LICENSE file for details.
|
||||
Reference in New Issue
Block a user