Spaces:
Sleeping
Sleeping
|
Download README.md from low-key-007/crypto-api: direct link, hf CLI and curl.
- Browser
- Download file 4.81 kB
-
https://huggingface.co/spaces/low-key-007/crypto-api/resolve/main/README.md
- Command line
-
hf download hf://spaces/low-key-007/crypto-api/README.md
-
curl -L -o README.md https://huggingface.co/spaces/low-key-007/crypto-api/resolve/main/README.md
4.81 kB
| 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/<uuid>` 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 | |
|  | |
|  | |
|  | |
|  | |
| > **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. | |