Image Encryption Algorithm Based On DCT Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Abstract - Image Encryption is a wide area of research. Encryption basically deals with converting data or information from its original form to some other form that hides the information in it. The protection of image data from unauthorized access is important. Encryption is employed to increase the data security. The Encrypted Image should be secure from any kind cryptanalysis.

The main attraction of the proposed system is after encryption the type of data encrypted will not be know i.e whether the data encrypted was text, image, video. For hiding the type of data encrypted after encryption the image is stored in an unformatted mode .In the proposed work, the image to be encrypted is decomposed into 8X8 blocks, these blocks are transformed from the spatial domain to frequency domain by the Discrete Cosine Transform(DCT). The DCT coefficients are XORed with pseudorandom number, Pseudorandom bit is generated by Non-Linear Shift back Register. The bits generated by Non-Linear Shift back Register can not be predicted so cryptanalysis becomes difficult. For decryption the encrypted image in the unformatted mode is read, and XORed with pseudorandom number and Inverse Discrete Cosine Transform(IDCT) is taken to convert the data from frequency domain to spatial domain.

Keywords - Encryption, Decryption, DCT, IDCT


Nowadays with the introduction of internet, faster transmission of large volume of important and valuable information is possible. Since internet has many points of access, it is vulnerable to many kinds of attack. So this information need to be protected from unauthorized access. To protect data from unauthorized access there are many Data Protection techniques like NULL'ing Out, Masking Data, Watermarking, Encryption, Stenography etc. Previously encryption was widely used for text data, but now it is used for images also. As its the need of the hour to protect image data from unauthorized access and manipulation, since image also carries valuable information like medical reports, defense data etc.

Data Encryption is one of the widely used techniques for data protection. In Data Encryption, data is converted

from its original to other form so that information cannot be accessed from the data without decrypting the data i.e

the reverse process of encryption. The original data is usually referred as plain data and the converted form is

called cipher data. Encryption is also referred as enciphering. Encryption can be defined as the art of converting data into coded form which can be decode by intended receiver only who poses knowledge about the decryption of the ciphered data. Encryption can be applied

to text, image, video for data protection. An encryption is unconditionally secure if the cipher text generated by the scheme does not contain enough information to determine uniquely the corresponding plaintext, no matter how much cipher text is available. An encryption algorithm is computationally secure if the cost of breaking the cipher exceeds the value of the encrypted information and the time required to break the cipher exceeds the useful lifetime of the information. Decryption is the technique of obtaining the original image from the encrypted image. Techniques used for deciphering a message without any knowledge of the enciphering fall into the area of cryptanalysis. The area of cryptography and cryptanalysis are together called as cryptology [15].

Selective Encryption of Human Skin In JPEG Images[5] provided selective encryption in the Huffman coding of the Discrete Cosine Transform(DCT) coefficients using Advanced encryption Standard(AES). Selective encryption is applicable where lower level of security is enough. It also reduces computational requirement Image.

A New Steganography Approach for Image Encryption Exchange by Using the Least Significant Bit Insertion [6], In this algorithm image is encrypted and embeds the data in the Least Significant Bits (LSB) in each byte of the image prior to transmission. The data is converted to binary representation before overwriting the LSB of each byte within the encrypted image randomly. The size of the image increases due to the added redundancy. This adds an additional overhead to decrypt the image. The disadvantage with all the cryptography system is that anyone who observes an encrypted message in transit can assume that the sender of the message is transmitting some secret information. This makes it possible to deduce the valuable information. Steganography helps to overcome this. A partial Image Encryption Scheme based on the DWT and Chaotic Stream Cipher [10]. This scheme aims to reduce encryption time by encrypting part of the image. The encryption is based on Chaotic Stream Cipher. A number of logistic and quadratic chaotic maps are used to produce the cipher. Chaotic maps are extremely dynamic and sensitive to change in initial conditions. Both the encryption and scrambling algorithm depends on multiple chaotic systems and are affected by the Initialization Vector(IV) ensuring they are dynamic and secure. IV value changes each time the message is encrypted. An Encryption algorithm based on knight tour is proposed [12], it is based on the L-shape move of the knight in chessboard. Firstly, a knight's tour matrix emended as slip encryption-filter template matrix is produced and then produces a knight's tour matrix again with the same size of the image waiting for encryption as a knight's tour slip matrix. Finally, let the centre of the slip encryption-filter template move along with the knight's tour slip matrix to do convulsion operation, and achieve the cipher image. The encryption is resistant to many kind cryptanalysis. In [13] an Asymmetric Image Encryption technique is discussed, two keys pairs are used - one public key and one private key. Private Key is used for encryption and the corresponding public key is used for decryption. Here the image to encrypt is divided to N x N blocks and transformed to DCT domain from spatial domain. The frontal coefficients of every P x P block is encrypted. IDCT is applied and the encrypted image is generated. For decryption, the DCT coefficients are generated and the frontal coefficients are decrypted. The advantages of the system is that it provides greater level of security since two different keys are used for encryption and decryption. It has good property of localization for the possible changed region. The drawback of the system is that sometimes it may be subjected to brute force attack, i.e. when decrypted with wrong key the resultant image may have some property of original image. In one of the latest research paper in partial Encryption [2], the image to be encrypted is converted from spatial domain to frequency domain by applying DCT. Then selected higher coefficients are encrypted and the remaining coefficients are shuffled. This technique may not work well with all the images, particularly images with edges. Even after encryption, some information regarding the original image will be there in cipher image.

In the proposed system, Encryption is employed to enhance image security. For encryption, first the image is converted from spatial domain to frequency domain by using Discrete Cosine Transform (DCT). The DCT represents an image as a sum of sinusoids of varying magnitudes and frequencies[2]. Many well known text encryption techniques are not well suited for image as images need very large storage space. The objective of proposed system includes protection of information and property from theft, corruption while allowing the information to remain accessible and productive to its intended users. This includes the collective processes and mechanisms by which sensitive and valuable information and services are protected from publication, tampering or collapse by unauthorized activities or untrustworthy individuals and unplanned events respectively. The system is designed with simplicity and security in mind.

In all the existing cryptosystem without any effort, adversary is able to get important information about the encrypted data like whether the encrypted data is text, image or video. This helps the adversary to plan data extraction or decryption accordingly. In the proposed system, this disadvantage is overcome by writing the data in unformatted mode after encryption. This helps to protect the information regarding the type of data encrypted.


The proposed system is designed to encrypt and decrypt images in secure, fast and simple way. This technique is easy to implement and secure. In the proposed scheme the image to be encrypted is first converted from spatial domain to frequency domain by using DCT and IDCT is used to convert the image back to spatial domain. The DCT coefficients are Xored with Pseudorandom number. After encryption, the image is saved in an unformatted file. This helps to make the encryption more secure, as it will not be able to know that the data in the unformatted file represents an image. For decryption, this unformatted file is read and Xored with pseudorandom number, and IDCT is taken and decrypted image is obtained.

The following steps give a brief idea about the methodology involved in encryption and decryption


Input image to be encrypted

Divide the image into 8x8 blocks.

Perform DCT on all this blocks and save the results coefficients in another array.

The selected coefficient is XORed with a random number generated by random number generator.

Save the encrypted image as an unformatted file.


Read the encrypted image which is in the unformatted file.

Read the file and XOR the data with the random numbers generated by a random number generator.

Divide the image into 8 by 8 blocks.

Perform IDCT, which will convert the data back to spatial domain, thus giving us the decrypted image.

Decrypted Image is obtained.

Both the process of encryption and Decryption require a set of pseudorandom number. Pseudorandom numbers have various cryptographic applications. For the generation of pseudorandom number an initial value is required and it is called as seed, based on this seed pseudorandom number is generated. Instead of generating a large number of pseudorandom number , a set of pseudorandom numbers can be generated and reused. Many pseudorandom number generation algorithm exist, one algorithm suggested by Lehmer called Linear Congruential Generators [15] is commonly used.


Experiments show that the proposed encryption technique works successfully in a fast and secure manner.

The proposed system is implemented successfully and the following results are obtained.

Experiment No: 1

Fig:6.1 a) Original Image

Fig: 6.2 b) Encrypted Image

The encrypted image does not hold any information of the original image, so it is difficult to decrypt the image without proper knowledge of decryption algorithm and the key used for generation of random number.

The decrypted image is obtained successfully. Most of the cryptosystem fails to obtain the decrypted image lossless. Even if the decrypted image is obtained there may be more or less distortion in the original image, but experiment shows the decrypted image through the implementation of the proposed scheme is obtained with very little loss of information that can be practically ignored.

Fig: 6.2 c) Decrypted Image

The proposed system is tested with various other sample images and found to work successfully.


In the proposed work, the image to be encrypted is read and the image is divided into 8X8 blocks, then DCT is taken for each of this block. Then, the obtained result is stored in a array. These coefficients are than Xored with pseudorandom number. In the proposed work, only five pseudorandom numbers are generated and Xored with first five DCT coefficients and again the same pseudorandom are Xored with second five coefficients. The process continues till all the coefficients are Xored with pseudorandom numbers. After these steps, an encrypted image is obtained but encryption is not yet over according to the proposed algorithm. Next the encrypted image is written in a unformatted file. The resultant unformatted file is the outcome of encryption of the image.

Encryption is a widely used technique and encryption is considered successful only if we are able to recollect the information i.e we should be able to decrypt the image with no or very little distortion. So while implement any step in encryption we should be careful to check if the step is reversible. If the encryption algorithm is reversible then only it is considered as good encryption algorithm since decryption is the reverse process of encryption. In all the existing systems after encryption the data is in the same format, if the data is text , after encryption it will be encrypted text, if the data is image it will be encrypted image. So without doing anything the adversary is able to find whether the information transferred is text, image or video. This is one of the main drawbacks of all the existing systems. This disadvantage is overcome in the proposed system.

Existing Systems

Proposed System

After encryption the type of data encrypted is known.

After encryption the type of data encrypted is not known.

Some algorithm are practically difficult to


Very easy to implement

Operates in frequency/Spatial domain

Operates in frequency

After encryption data is saved as it is.

After encryption data is saved in unformatted mode.

Table:4.1 Comparisons between proposed and Existing Systems


In this project, a technique for faster image encryption is proposed. Here we are working in frequency domain, for that the image is first converted from spatial domain to frequency. For making encryption faster and to reduce the time complexity, various usually used techniques for encryption like scrambling, compression are avoided in the proposed methodology. Compression is not included in this method since compression requirement for each image is not unique. To add additional security to the image in the cryptosystem, after encrypting the selected coefficients, all the coefficients can also be scrambled. Here scrambling is also avoided to minimize the time complexity required for encryption.

As a further extension of this work, encryption can be extended for video. In the proposed system, once the image is recovered after decryption, there is minor loss of information. This loss is not significant. As a future enhancement, system should be designed to withstand any loss of information. There is also an increase in the size of image after encryption when saved in unformatted file. As a future extension of this work some compression technique can be included.