--- title: Crypto Api emoji: 🐨 colorFrom: indigo colorTo: blue sdk: docker pinned: false license: mit --- # Crypto-Stego API (FastAPI + Docker) A lightweight API wrapper around your three modules: - `sender.py` — encrypts the cover image and produces two Fernet keys. - `embbed.py` — embeds a secret image into the encrypted image and appends a third key. - `retreive.py` — reconstructs the encrypted image and retrieves the secret image. ## Endpoints 1. `POST /encrypt` — form-data with `image` (file). Returns: - `encrypted_image` (download URL) - `aes_key`, `aes_key_2` - `run_dir` (use for subsequent steps) 2. `POST /embed` — form-data with: - `run_dir` (string from `/encrypt` response) - `secret_image` (file) Returns: - `stego_image` (download URL) - `secret_shuffle_key` 3. `POST /retrieve` — form-data with: - `run_dir` - JSON body: `{ "aes_key": "...", "aes_key_2": "...", "secret_shuffle_key": "..." }` Returns: - `constructed_image`, `retrieved_secret_image` (download URLs) - Metrics: RMSE and entropy Each request runs inside an isolated `runs/` directory to avoid cross-request collisions. ## Run locally ```bash docker build -t crypto-stego . docker run -p 7860:7860 crypto-stego if you want to test or acces my website follow this link : "https://kaleidoscopic-platypus-4af4a4.netlify.app/" Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference # 🔐 CipherStego: Secure Block-Based Image Steganography ![Python](https://img.shields.io/badge/Python-3.10-blue?logo=python&logoColor=white) ![FastAPI](https://img.shields.io/badge/Framework-FastAPI-green?logo=fastapi&logoColor=white) ![Cryptography](https://img.shields.io/badge/Security-AES_Fernet-red) ![Status](https://img.shields.io/badge/Research-Prototype-orange) > **CipherStego** is a hybrid security framework combining **Cryptography** and **Steganography**. It utilizes a dual-layer shuffling mechanism (Block & Pixel permutation) combined with LSB (Least Significant Bit) insertion to ensure high visual imperceptibility and robust data hiding. --- ## 🔬 Abstract & Methodology Traditional steganography is vulnerable to steganalysis if the cover image statistical properties are altered significantly. CipherStego mitigates this by encrypting the cover image *before* embedding, a technique known as **Encrypted Domain Data Hiding**. ### Key Algorithms: 1. **Block Permutation (Key 1):** The image is divided into $2 \times 2$ matrices. The positions of these blocks are shuffled using a chaotic map generated by a Fernet key. 2. **Intra-Block Diffusion (Key 2):** Pixels within each block are permuted to destroy local correlation. 3. **LSB Embedding (Key 3):** The secret image is flattened and embedded into the Least Significant Bits of the encrypted cover. --- ## 🏗 System Architecture The system operates on a **3-Key Authentication** principle. * **Level 1 Access:** View the "Constructed" (Encrypted) image. * **Level 2 Access:** Decrypt the cover image. * **Level 3 Access (Root):** Extract the hidden secret image. ```mermaid graph TD subgraph "Sender Side" Cover[🖼️ Cover Image] Secret[🤫 Secret Image] Cover -->|Key 1: Block Shuffle| Encrypt[🔒 Encrypted Domain] Encrypt -->|Key 2: Pixel Shuffle| Encrypt Secret -->|Key 3: Bit Stream| Embedder[📥 LSB Embedder] Encrypt --> Embedder Embedder --> Stego[📦 Stego Image] end subgraph "Receiver Side" Stego -->|Input| Extractor[📤 Data Extractor] Extractor -->|Keys 1 & 2| Construct[🖼️ Reconstruct Cover] Extractor -->|Key 3| Hidden[🤫 Extract Secret] end 📊 Performance Metrics The system evaluates the quality of the steganography using standard research metrics: RMSE (Root Mean Square Error): Measures the difference between the original cover and the reconstructed image. Lower is better. $$ RMSE = \sqrt{\frac{1}{MN} \sum (I_{orig} - I_{stego})^2} $$ Entropy: Measures the randomness of the encrypted image. A value closer to 8 (for 8-bit images) indicates better encryption. Component,Technology,Description Backend,FastAPI,Asynchronous REST API for handling image uploads. Crypto,Fernet (AES),Symmetric key encryption for shuffling vectors. Processing,NumPy,High-performance matrix manipulation for 2x2 blocks. Imaging,Pillow (PIL),Image I/O and format conversion. 👨‍💻 Developer's Note This project was developed to explore the trade-offs between Embedding Capacity and Visual Imperceptibility. Future improvements include implementing Discrete Cosine Transform (DCT) for frequency-domain embedding to improve resistance against compression attacks.