
- Cryptography - Home
- Cryptography - Origin
- Cryptography - History
- Cryptography - Principles
- Cryptography - Applications
- Cryptography - Benefits & Drawbacks
- Cryptography - Modern Age
- Cryptography - Traditional Ciphers
- Cryptography - Need for Encryption
- Cryptography - Double Strength Encryption
- Cryptosystems
- Cryptosystems
- Cryptosystems - Components
- Attacks On Cryptosystem
- Cryptosystems - Rainbow table attack
- Cryptosystems - Dictionary attack
- Cryptosystems - Brute force attack
- Cryptosystems - Cryptanalysis Techniques
- Types of Cryptography
- Cryptosystems - Types
- Public Key Encryption
- Modern Symmetric Key Encryption
- Cryptography Hash functions
- Key Management
- Cryptosystems - Key Generation
- Cryptosystems - Key Storage
- Cryptosystems - Key Distribution
- Cryptosystems - Key Revocation
- Block Ciphers
- Cryptosystems - Stream Cipher
- Cryptography - Block Cipher
- Cryptography - Feistel Block Cipher
- Block Cipher Modes of Operation
- Block Cipher Modes of Operation
- Electronic Code Book (ECB) Mode
- Cipher Block Chaining (CBC) Mode
- Cipher Feedback (CFB) Mode
- Output Feedback (OFB) Mode
- Counter (CTR) Mode
- Classic Ciphers
- Cryptography - Reverse Cipher
- Cryptography - Caesar Cipher
- Cryptography - ROT13 Algorithm
- Cryptography - Transposition Cipher
- Cryptography - Encryption Transposition Cipher
- Cryptography - Decryption Transposition Cipher
- Cryptography - Multiplicative Cipher
- Cryptography - Affine Ciphers
- Cryptography - Simple Substitution Cipher
- Cryptography - Encryption of Simple Substitution Cipher
- Cryptography - Decryption of Simple Substitution Cipher
- Cryptography - Vigenere Cipher
- Cryptography - Implementing Vigenere Cipher
- Modern Ciphers
- Base64 Encoding & Decoding
- Cryptography - XOR Encryption
- Substitution techniques
- Cryptography - MonoAlphabetic Cipher
- Cryptography - Hacking Monoalphabetic Cipher
- Cryptography - Polyalphabetic Cipher
- Cryptography - Playfair Cipher
- Cryptography - Hill Cipher
- Polyalphabetic Ciphers
- Cryptography - One-Time Pad Cipher
- Implementation of One Time Pad Cipher
- Cryptography - Transposition Techniques
- Cryptography - Rail Fence Cipher
- Cryptography - Columnar Transposition
- Cryptography - Steganography
- Symmetric Algorithms
- Cryptography - Data Encryption
- Cryptography - Encryption Algorithms
- Cryptography - Data Encryption Standard
- Cryptography - Triple DES
- Cryptography - Double DES
- Advanced Encryption Standard
- Cryptography - AES Structure
- Cryptography - AES Transformation Function
- Cryptography - Substitute Bytes Transformation
- Cryptography - ShiftRows Transformation
- Cryptography - MixColumns Transformation
- Cryptography - AddRoundKey Transformation
- Cryptography - AES Key Expansion Algorithm
- Cryptography - Blowfish Algorithm
- Cryptography - SHA Algorithm
- Cryptography - RC4 Algorithm
- Cryptography - Camellia Encryption Algorithm
- Cryptography - ChaCha20 Encryption Algorithm
- Cryptography - CAST5 Encryption Algorithm
- Cryptography - SEED Encryption Algorithm
- Cryptography - SM4 Encryption Algorithm
- IDEA - International Data Encryption Algorithm
- Public Key (Asymmetric) Cryptography Algorithms
- Cryptography - RSA Algorithm
- Cryptography - RSA Encryption
- Cryptography - RSA Decryption
- Cryptography - Creating RSA Keys
- Cryptography - Hacking RSA Cipher
- Cryptography - ECDSA Algorithm
- Cryptography - DSA Algorithm
- Cryptography - Diffie-Hellman Algorithm
- Data Integrity in Cryptography
- Data Integrity in Cryptography
- Message Authentication
- Cryptography Digital signatures
- Public Key Infrastructure
- Hashing
- MD5 (Message Digest Algorithm 5)
- SHA-1 (Secure Hash Algorithm 1)
- SHA-256 (Secure Hash Algorithm 256-bit)
- SHA-512 (Secure Hash Algorithm 512-bit)
- SHA-3 (Secure Hash Algorithm 3)
- Hashing Passwords
- Bcrypt Hashing Module
- Modern Cryptography
- Quantum Cryptography
- Post-Quantum Cryptography
- Cryptographic Protocols
- Cryptography - SSL/TLS Protocol
- Cryptography - SSH Protocol
- Cryptography - IPsec Protocol
- Cryptography - PGP Protocol
- Image & File Cryptography
- Cryptography - Image
- Cryptography - File
- Steganography - Image
- File Encryption and Decryption
- Cryptography - Encryption of files
- Cryptography - Decryption of files
- Cryptography in IoT
- IoT security challenges, Threats and Attacks
- Cryptographic Techniques for IoT Security
- Communication Protocols for IoT Devices
- Commonly Used Cryptography Techniques
- Custom Building Cryptography Algorithms (Hybrid Cryptography)
- Cloud Cryptography
- Quantum Cryptography
- Image Steganography in Cryptography
- DNA Cryptography
- One Time Password (OTP) algorithm in Cryptography
- Difference Between
- Cryptography - MD5 vs SHA1
- Cryptography - RSA vs DSA
- Cryptography - RSA vs Diffie-Hellman
- Cryptography vs Cryptology
- Cryptography - Cryptology vs Cryptanalysis
- Cryptography - Classical vs Quantum
- Cryptography vs Steganography
- Cryptography vs Encryption
- Cryptography vs Cyber Security
- Cryptography - Stream Cipher vs Block Cipher
- Cryptography - AES vs DES ciphers
- Cryptography - Symmetric vs Asymmetric
Cryptography − Image
As digital images play an ever more important role in multimedia technologies, it is important that users keep their privacy. To provide such protection and privacy to the user, image encryption is necessary to prevent against unauthorised user access.
- Image and video encryption have a wide range of applications, like internet communication, multimedia systems, medical imaging, telemedicine, and military communications.
- Because of the fast development in multimedia and network technology, colour images are being transmitted and stored in large quantities across the Internet and wireless networks.
- Cryptography continues to play a key part in the subject of security, and several cryptographic algorithms have been proposed in the past, like AES, DES, RSA, and IDEA.
- The methods used for encrypting images and data are not the same. There are various security risks involved with digital image processing and transmission, so it is important to ensure image integrity and confidentiality. Also, digital images are less sensitive than data because a single change in pixels does not affect the entire image.
In other words, a minor modification to a digital image is acceptable when compared to data, but it is more vulnerable to attackers. In the below image we can see a general image encryption method with any image encryption technique and the resulting encrypted image.

Image Cryptography Techniques
Here are some simple techniques used in image cryptography −
- Steganography − This method hides confidential information from image without much changing the image's look. It can involve concealing data, messages, or even images within an image's pixels. The least important parts of pixel values can be changed, or specific parts of the image where changes are less visible can be used to hide the hidden data.
- Substitution Ciphers − Using a predefined rule or key each pixel value in the image is replaced with a different value in this method. To scramble the pixel values and render the image unreadable without the right decryption key, this substitution can be based on mathematical processes like addition, subtraction, or bitwise operations.
- Permutation Ciphers − These ciphers rearrange the image's pixels as per the predetermined pattern or permutation key, compared to changing the pixel values. The image's spatial layout is changed by this rearrangement, giving it a scrambled or distorted appearance. Only the people who have the right code can put the pixels back where they belong in the image.
- Encryption Algorithms − The complete image data can be encrypted with the help of advanced encryption algorithms like Rivest Cipher (RSA) or Advanced Encryption Standard (AES). These methods help us to scramble the image data with the help of complex mathematical processes and keys which makes it unrecognizable without the correct decryption key.
- Watermarking − Watermarking is like inserting a hidden mark or signature inside an image in order to verify its validity or ownership. Watermarks can be visible or invisible. They are mainly used to prevent unauthorized use or distribution of digital photographs.
Need for Image Cryptography
Image cryptography has many major applications in the digital world −
- Confidentiality − Image cryptography guarantees only authorized people have access to the image's content. Encrypting the image data makes it unreadable to anybody without the decryption key, means it is preserving confidentiality.
- Integrity − Cryptography can be used to check an integrity of the image, ensuring that it was not changed or altered with during transmission or storage. Digital signatures and hash algorithms can be used to detect unauthorized picture alterations.
- Authentication − Cryptographic techniques can be used to verify the origin and authenticity of an image. Digital signatures and watermarking are standard methods to offer verification of an image's source and ensuring that it has not been forged.
- Secure Transmission − Cryptography can protect photos sent across networks or stored in the cloud against theft or unauthorised access. Encryption ensures that no matter how an attacker intercepts the image data, they are unable to decipher its contents without the decryption key.
- Compliance − Some industries or applications like healthcare or law enforcement have major image confidentiality and security requirements. image cryptography can help businesses comply with these rules by protecting sensitive image data.
- Security from Data Theft − Images may include sensitive or important information like intellectual property, personal data, or company secrets. Image cryptography minimizes the risk of data theft by making image data unreadable to unauthorized users.
Implementation of Image Encryption
We will add random noise to an image using different programming languages: Python, C, C++, and Java. For this, we will use the Pillow and NumPy libraries in Python, while OpenCV will be used for C, C++, and Java.
- Pillow is a powerful library for image processing, enabling us to open, manipulate, and save images. In our implementation, we use Pillow to open the input image, convert it to gray-scale, and create a new noisy image.
- OpenCV, on the other hand, provides image-processing capabilities in C++ allowing us to smoothly handle image operations and noise generation.
- NumPy is a widely used numerical computing library in Python. In our implementation, it converts the image into a NumPy array and generates random noise, which is then added to the original image using element-wise addition. In C++ OpenCV's randn() function is used to generate Gaussian noise.
Finally, we ensure that pixel values remain within the valid range of 0-255 before saving the new noisy image.
Example
So the implementation for image encryption in python and C++ is as follows −
#include <opencv4/opencv2/opencv.hpp> #include <cstdlib> #include <ctime> #include <iostream> void add_noise(const std::string& image_path, double noise_factor) { cv::Mat image = cv::imread("C://Users/Tutorialspoint/Desktop/Cryptography/images/my_image.jpeg", cv::IMREAD_GRAYSCALE); if (image.empty()) { std::cerr << "Error: Cannot open image!" << std::endl; return; } cv::Mat noise(image.size(), image.type()); cv::randn(noise, 0, noise_factor); cv::Mat noisy_image = image + noise; cv::threshold(noisy_image, noisy_image, 255, 255, cv::THRESH_TRUNC); cv::threshold(noisy_image, noisy_image, 0, 0, cv::THRESH_TOZERO); cv::imwrite("C://Users/Tutorialspoint/Desktop/Cryptography/images/noisy_img.jpg", noisy_image); std::cout << "Noise added successfully!" << std::endl; } int main() { add_noise("C://Users/Tutorialspoint/Desktop/Cryptography/images/my_image.jpeg", 50.0); // Add noise with factor 50 return 0; }
Output
The output produced is as follows −
Noise added successfully!
Following was our original image "my_image.jpeg" −

Following is the noisy image "noisy_img.jpg" obtained −

from PIL import Image import numpy as np import os # Function to add noise to the image def add_noise(image_path, noise_factor): # Check if file exists if not os.path.exists(image_path): print(f"Error: File '{image_path}' not found!") return None # Open the image image = Image.open(image_path) # Convert to grayscale image = image.convert('L') # Convert image to numpy array img_arr = np.array(image, dtype=np.float32) # Convert to float for precision # Generate random noise noise = np.random.normal(scale=noise_factor, size=img_arr.shape) # Add noise and clip values to valid range [0, 255] noisy_img_arr = np.clip(img_arr + noise, 0, 255).astype(np.uint8) # Create a new noisy image noisy_img = Image.fromarray(noisy_img_arr) return noisy_img # Path to the image file (use raw string format) image_path = r"C:\Users\Tutorialspoint\Desktop\Cryptography\images\my_image.jpeg" # Noise factor noise_factor = 20 # Reduced to prevent excessive noise # Add noise to the image noisy_img = add_noise(image_path, noise_factor) if noisy_img: # Save and show the noisy image noisy_img.save(r'C:\Users\Tutorialspoint\Desktop\Cryptography\images\noisy_img.jpg') noisy_img.show() print("Noise has been added to the image successfully!")
Output
Following is the output of the above code −
Noise has been added to the image successfully!
Following was our original image "my_image.jpeg" −

Following is the noisy image "noisy_img.jpg" obtained −

Drawbacks of Image Cryptography
Below are some drawbacks of image cryptography we should consider while working with it −
- Implementing image cryptography can be difficult and needs special understanding of cryptographic algorithms and procedures.
- Encrypting and decrypting images can result in computational cost, which may impact system performance, specially with large image files or real-time applications.
- Image cryptography depends primarily on proper encryption key management. Missing or corrupting the encryption keys can result in permanent loss of access to encrypted images.
- Image cryptography like any other security system is vulnerable to compromise. Poor encryption methods implementation errors and key management refers to could harm the security of encrypted images.
- Encrypted images can not be suitable with all image processing tools or platforms, reducing their usability or interoperability.