Skip to content
bhavya70020Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Task 02: Pixel Manipulation for Image Encryption

A Python-based image encryption and decryption tool that manipulates pixel values using a mathematical XOR (Bitwise Exclusive OR) operation with a user-defined key.


📌 Overview

This project demonstrates basic cryptographic principles applied to computer graphics and digital imagery. By iterating through each pixel in an RGB image and applying a bitwise XOR operation with a 1-byte numeric key (0 to 255), the original image data is scrambled into an unrecognizable encrypted state. Applying the same key again reverses the operation and perfectly restores the original image.

✨ Features

  • Symmetric Encryption/Decryption: Uses XOR arithmetic, meaning the exact same process with the same key restores the original image.
  • RGB Channel Support: Manipulates all three color channels (Red, Green, Blue) across the whole image dimension.
  • Customizable Output Format: Saves processed images to formats like PNG, JPG, JPEG.

🛠️ Tech Stack & Requirements

📦 Installation

Make sure you have Pillow installed:

pip install pillow

🚀 How to Run

  1. Place your input image into the task2 folder (e.g., original.png or original.jpg).
  2. Run the script:
python main.py
  1. Follow the interactive prompts:
    • Select operation: 1 for encryption or 2 for decryption.
    • Enter a key: An integer between 0 and 255.
    • Enter output file name (e.g., encrypted.png or decrypted.png).

💡 Example Workflow

  1. Encrypting an Image:

    Choose your preference
    1. encryption
    2. decryption
                       
    Your choice: 1
    Give a key (must be from 0 to 255): 123
    Give a name to your image with image type(png,jpg,jpeg): encrypted.png
    

    Output: image saved successfully as encrypted.png

  2. Decrypting the Image:

    Choose your preference
    1. encryption
    2. decryption
                       
    Your choice: 2
    Give a key (must be from 0 to 255): 123
    Give a name to your image with image type(png,jpg,jpeg): decrypted.png
    

    Output: image saved successfully as decrypted.png


📂 File Structure

task2/
├── main.py        # Python script for image encryption/decryption
├── original.jpg   # Sample input image
└── README.md      # Documentation

⚠️ Notes

  • When saving encrypted images, it is recommended to use lossless formats such as PNG to prevent lossy compression algorithms (like JPEG) from altering pixel values and causing decryption artifacts.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages