0

You might also like

Download as pdf
Download as pdf
You are on page 1of 6
ecard IMAGE ENCRYPTION rT Tem Nt) ALGORITHM PROJECT Image Encryption Using AES Algorithm Project Table of Contents => Introduction In today's digital age, the secure transmission and storage of digital images have become paramount. This is particularly true for sectors like healthcare, military, and multimedia systems. This article explores the use of the ‘Advanced Encryption Standard (AES) algorithm for image encryption and decryption, offering a secure solution for protecting digital images against unauthorized access. Start for free 24 8 Eno ro Pr Why AES for Image Encryption? AES stands out for its robustness and security features, making it a preferred choice over other encryption methods like DES (Data Encryption Standard) and Triple DES. AES uses a key size of 192 bits, enhancing the security of the encryption and decryption process. How AES Works for Image Encryption The AES algorithm encrypts the digital image by converting it into a series of blocks and then applying multiple rounds of substitution, permutation, and mixing functions. The key, known only to the sender and receiver, is used to encrypt and decrypt the image, ensuring that only authorized parties can view it. DES and Triple DES. * Confidentiality: Only the sender and receiver, who have the key, can view the encrypted image. + Robust Key Size: The 192-bit key size makes the encryption and decryption process highly secure, Disadvantages * Increased File Size: The encrypted image file size becomes large, which can be a drawback in some applications. + Potential for Suspicion: The large file size may raise suspicions that the file contains critical information. Applications AES-based image encryption is widely used in: * Internet communication ‘+ Medical imaging systems * Military applications + Multimedia systems Conclusion Image encryption using the AES algorithm offers a reliable and secure method for the protection of digital images. While it does have some drawbacks, such as increased file size, the benefits far outweigh the stall the required packages: pip install Pillow pip install pycryptodome fron PIL import Image from Crypto.Cipher import AES import os # Function to pad data to be 16-byte aligned def pad(data): return data + b"\xo0" * (16 - len(data) % 16) # Function to encrypt image def encrypt_image(image_path, key_path, encrypted_path) # Open image and convert to byte array img = Image.open(image_path) img_byte_arr = ing.tobytes() # Pad image byte array to be 16-byte aligned ing_byte_arr pad(img_byte_arr) # Create AES cipher object key = open(key_path, "rb").read() cipher = AES.new(key, AES.NODE_ECB) # Encrypt image byte array # Function to decrypt image def decrypt_image(encrypted_path, key_path, decrypted_path): # Open encrypted image and convert to byte array encrypted_img = Image.open(encrypted_path) encrypted_img_byte_arr = encrypted_img. tobytes() # Create AES cipher object key = open(key_path, "rb").read() cipher = AES.new(key, AES.NODE_ECB) # Decrypt image byte array decrypted_ing_byte_arr = cipher. decrypt (encrypted_img_byte_arr) # Save decrypted image decrypted_img = Image. frombytes(encrypted_img.mode, encrypted_ing.size, decrypted_ing_byte_arr) decrypted_img. save(decrypted_path) # Generate a random 192-bit key and save it key = 0s.urandom(24) with open("key.key", “wb") as key file: key_file.write(key) # Paths image_path = “original_image.jpg" # Replace with your image path key_path = “key.key” encrypted_path = “encrypted_inage. ipa” decrypted_path = “decrypted_imege. ipa” # Encrypt and decrypt image encrypt_image(image_path, key_path, encrypted_path) decrypt_image(encrypted_path, key_path, decrypted_path) Replace original_image. jpg with the path to the image you want to encrypt. This code will save the encrypted image as encrypted_inage. Jpg and the decrypted image as decrypted_image. jpg. Click to rate this post! ur Average: 0] GenAl is changing the game Mongone Ata

You might also like