Skip to content

another cipher app for encryption of text based data, mainly an obfuscation tool to make brufeforcing almost impossible and sensitive data useless in case of data breach, you will need your own algo but here is an experiemental and educatioal version, must use as api far away from your main asset or infracture

License

Notifications You must be signed in to change notification settings

razielapps/chaocrypt_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chaocrypt API v3

A Django REST Framework API for the Chaocrypt v3 encryption algorithm. This service provides endpoints for encrypting and decrypting text using a custom cipher algorithm with multiple security levels.

Features

  • πŸ”’ Multi-level encryption: Basic, Medium, and Advanced security levels
  • πŸ”„ Bidirectional conversion: Encrypt plaintext to ciphertext and decrypt back
  • πŸ“¦ Batch processing: Encrypt multiple texts in a single request
  • πŸ›‘οΈ Production-ready: Error handling, validation, and logging
  • πŸ“Š Health monitoring: Built-in health check endpoint
  • πŸ” Cipher information: Detailed information about the encryption algorithm

Installation

Prerequisites

  • Python 3.8+
  • Django 3.2+
  • Django REST Framework 3.12+

Setup

  1. Clone and install dependencies:
pip install django djangorestframework
  1. Add to Django settings:
INSTALLED_APPS = [
    ...,
    'rest_framework',
    'chaocrypt',  # Your app name
]
  1. Configure URLs in your project's urls.py:
from django.urls import path, include

urlpatterns = [
    ...,
    path('api/', include('chaocrypt.urls')),
]

API Endpoints

1. Health Check

GET /api/health/

{
    "status": "ok"
}

2. Encrypt Text

POST /api/encrypt/

{
    "text": "Hello World!",
    "level": "medium"  // "basic", "medium", or "advanced"
}

Response:

{
    "success": true,
    "original_text": "Hello World!",
    "encrypted_text": "109a507%12c114a507%12c...",
    "level": "m",
    "message": "Text encrypted successfully"
}

3. Decrypt Text

POST /api/decrypt/

{
    "encrypted_text": "109a507%12c114a507%12c..."
}

Response:

{
    "success": true,
    "encrypted_text": "109a507%12c114a507%12c...",
    "decrypted_text": "Hello World!",
    "message": "Text decrypted successfully"
}

4. Batch Encrypt

POST /api/batch-encrypt/

{
    "texts": ["Hello", "World", "123"],
    "level": "basic"
}

Response:

{
    "success": true,
    "level": "n",
    "results": [
        {
            "original_text": "Hello",
            "encrypted_text": "102a65%5c...",
            "error": null
        },
        ...
    ],
    "total": 3
}

5. Cipher Information

GET /api/info/

{
    "cipher_name": "Chaocrypt v3",
    "character_set_size": 70,
    "supported_characters": ["a", "b", "c", ...],
    "encryption_levels": {
        "n": "Normal (50-100)",
        "m": "Medium (500-1000)",
        "a": "Advanced (5000-10000)"
    },
    "format": "Each character becomes: number + random_letter + level%original_length + random_letter"
}

Encryption Algorithm

Overview

Chaocrypt v3 uses a substitution cipher with added salt and randomization:

  1. Character Mapping: Each character maps to a unique number (101-1069)
  2. Salt Addition: Adds salt based on text length and encryption level
  3. Randomization: Includes random letters and encryption level in output

Encryption Levels

  • Basic (n): Random salt between 50-100
  • Medium (m): Random salt between 500-1000
  • Advanced (a): Random salt between 5000-10000

Output Format

Each character is encrypted to:

[encrypted_number][random_letter][level]%[original_text_length][random_letter]

Example: 109a507%12c

Error Handling

The API returns appropriate HTTP status codes:

  • 200 OK: Success
  • 400 Bad Request: Invalid input
  • 500 Internal Server Error: Server-side error

Error responses include detailed messages:

{
    "error": "Text is required and must be a string"
}

Security Considerations

  1. Not for Production Security: This is a custom cipher for educational/demo purposes
  2. Randomization: Each encryption uses random salt values
  3. Input Validation: All inputs are validated and sanitized
  4. Error Messages: Generic error messages to avoid information leakage

Usage Examples

Python

import requests

# Encrypt
response = requests.post('http://localhost:8000/api/encrypt/', 
    json={'text': 'Secret Message', 'level': 'advanced'})
encrypted = response.json()['encrypted_text']

# Decrypt
response = requests.post('http://localhost:8000/api/decrypt/',
    json={'encrypted_text': encrypted})
decrypted = response.json()['decrypted_text']

cURL

# Encrypt
curl -X POST http://localhost:8000/api/encrypt/ \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello World", "level": "medium"}'

# Decrypt
curl -X POST http://localhost:8000/api/decrypt/ \
  -H "Content-Type: application/json" \
  -d '{"encrypted_text": "109a507%12c..."}'

JavaScript

// Encrypt
fetch('/api/encrypt/', {
    method: 'POST',
    headers: {'Content-Type': 'application/json'},
    body: JSON.stringify({text: 'Hello', level: 'basic'})
})
.then(response => response.json())
.then(data => console.log(data.encrypted_text));

Testing

Run Django tests:

python manage.py test chaocrypt

Development

Adding New Features

  1. Extend the character map in normal_case_map
  2. Add new encryption levels in the _encrypt_text method
  3. Create new endpoints by extending APIView

Known Limitations

  • Duplicate characters in original map were deduplicated (kept first occurrence)
  • Maximum text length is limited by performance considerations
  • Special characters support is comprehensive but not exhaustive

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes with tests
  4. Submit a pull request

License

MIT License - See LICENSE file for details.

Support

For issues and questions:

  1. Check the API documentation
  2. Review error messages in responses
  3. Ensure correct input format
  4. Check server logs for detailed errors

This idea is meant to slow down bruteforce attack and to render data useless in case of data breach, you will need your own algorithm and this is experimental and educational purpose.

Made by Conscience Ekhomwandolor with tap_drf

About

another cipher app for encryption of text based data, mainly an obfuscation tool to make brufeforcing almost impossible and sensitive data useless in case of data breach, you will need your own algo but here is an experiemental and educatioal version, must use as api far away from your main asset or infracture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published