Image encryption & decryption using xor
Image encryption & decryption using xor
LOAD
IMAGE SAVE ENCRYPTED
IMAGE
GENERATE
KEYSTREAM
DISPLAY
ENCRYPTED
IMAGE
CONVERT INTO
ARRAY
STOP
ALGORITHM
1. Importing Libraries:
• Import the necessary modules: tkinter, PIL (Python Imaging Library), and playsound.
2. Creating the Root Window:
• Create the main application window (root) using Tk().
• Set the title, icon, dimensions, and make the window non-resizable.
3. Setting Background Image:
• Load and resize a background image using PIL.
• Create a PhotoImage object from the resized image.
• Create a Label widget to display the background image.
4. Define Button Hover Functions:
• b2_hover_enter(e): Change button colors and display a status message when the
mouse enters the button area.
• b2_hover_leave(e): Restore button colors and clear the status message when the
mouse leaves the button area.
5. Define Image Selection Function:
• select_image(): Open a file dialog to select an image file.
• Store the selected file in the file1 variable.
6. Define Image Encryption Function:
• encrypt_image(): Read the selected image file and the encryption key from the user.
• Read the image file as binary data and store it in the image variable.
• Iterate through each byte of the image data and apply bitwise XOR with the integer
value of the encryption key.
• Write the modified image data back to the original file.
• Play a sound to indicate completion and clear the encryption key input field.
7. Create Widgets:
• Create a Text widget for the user to input the encryption key.
• Create buttons (b1 and b2) for selecting an image and initiating encryption.
• Create a status label at the bottom of the window.
8. Bind Events:
• Bind functions to button hover events using <Enter> and <Leave> event handlers.
• Start the Main Event Loop:
PSEUDO CODE
# Import necessary modules
import tkinter as tk
root = Tk()
def b2_hover_enter(e):
# Change button appearance and update status label
def b2_hover_leave(e):
# Restore button appearance and clear status label
# Encrypt each byte of the image using XOR operation with the key
EncryptImageData(image, key)
• https://www.101computing.net/xor-encryption-algorithm/
• https://www.mdpi.com/1099-4300/23/5/535
• https://tome.app/abcd-66e5/xortify-your-images-a-pythonic-journey-into-image-en
cryption-cljgmu9ji0ni1ms3cqu9itirj
• https://chat.openai.com/