Frequently Asked Question
encrypt - An Encryption and Decryption Toolkit API
Last Updated 7 days ago
Encrypt API
Overview
The Encrypt API provides functionality to encrypt and decrypt files using AES-256-GCM encryption. It includes metadata in the encrypted file and supports file upload.
Version
1.001
Endpoint
/v2/encrypt.php
Authentication
This API requires authentication using an API key. The key should be passed in the HTTP_X_API_KEY
header.
Request Parameters
Parameter | Type | Description |
---|---|---|
f | string | Function to perform: 'e' for encrypt, 'd' for decrypt (required) |
k | string | Encryption/decryption key (required, max 64 characters) |
d | file | File to be encrypted or decrypted (required) |
Response
The API returns a JSON object with the following structure:
Field | Type | Description |
---|---|---|
status | string | "success" or "error" |
function | string | The function performed ('e' or 'd') |
message | string | A message describing the result or error |
data | string | Base64 encoded processed data (encrypted or decrypted) |
filename | string | The name of the uploaded file |
metadata | object | Metadata of the decrypted file (only for decryption) |
Example Response (Encryption)
{
"status": "success",
"function": "e",
"message": "File processed successfully",
"data": "base64_encoded_encrypted_data",
"filename": "example.txt"
}
Example Response (Decryption)
{
"status": "success",
"function": "d",
"message": "File processed successfully",
"data": "base64_encoded_decrypted_data",
"filename": "encrypted_file.bin",
"metadata": {
"filename": "original_filename.txt",
"timestamp": 1623456789,
"version": "1.001"
}
}
Error Handling
- If the request method is not POST:
{"status": "error", "message": "Invalid request method"}
- If file upload fails:
{"status": "error", "message": "File upload failed"}
- If file contents can't be read:
{"status": "error", "message": "Failed to read file contents"}
- If an invalid function is specified:
{"status": "error", "message": "Invalid function"}
- If decryption fails:
{"status": "error", "message": "Decryption failed: [error details]"}
Notes
- The API uses AES-256-GCM encryption for secure file encryption and decryption.
- Encrypted files include metadata (original filename, timestamp, and version) in the header.
- The encryption key is hashed using SHA-256 before use.
- The API supports file uploads and processes the uploaded file directly.
- Any data is immediately removed when the function completes.
Security
- Ensure that the API key is kept secure and not exposed in client-side code.
- All responses are sent with the "Content-Type: application/json" header.
- The encryption key should be securely managed and transmitted.
- The API uses a secure encryption algorithm (AES-256-GCM) with proper IV generation and authentication.