A Novel Image Encryption using an Integration Technique of
Blocks Rotation based on the Magic cube and the AES Algorithm
Ahmed Bashir Abugharsa1, Abd Samad Bin Hasan Basari2 and Hamida Almangush3
1
Centre of Advanced Computing Technology,
Faculty of Information and Communication Technology, Universiti Teknikal Malaysia Melaka
Hang Tuah Jaya, 76100 Durian Tunggal, Melaka, MALAYSIA
2
Centre of Advanced Computing Technology,
Faculty of Information and Communication Technology, Universiti Teknikal Malaysia Melaka
Hang Tuah Jaya, 76100 Durian Tunggal, Melaka, MALAYSIA
3
Centre of Advanced Computing Technology,
Faculty of Information and Communication Technology, Universiti Teknikal Malaysia Melaka
Hang Tuah Jaya, 76100 Durian Tunggal, Melaka, MALAYSIA
Abstract transform has been presented. The amplitude and stage of the
In recent years, several encryption algorithms have been gyrator transform are divided into a number of sub-images,
proposed to protect digital images from cryptographic attacks. which are shuffled using the Arnold transform. The parameters of
These encryption algorithms typically use a relatively small key the gyrator transforms and the separation algorithm provide the
space and therefore, provide safe, especially if they are of a key for the encryption process.
dimension. In this paper proposes an encryption algorithm for a
new image protection scheme based on the rotation of the faces Tao et al. [5] proposed an image encryption algorithm based on
of a Magic Cube. The original image is divided into six sub- the fractional Fourier transform (FRFT) which can be applied to
images and these sub-images are divided amongst a number of double or more image encryptions. The encrypted image is
blocks and attached to the faces of a Magic Cube. The faces are achieved by the summation of different orders of inverse discrete
then scrambled using rotation of the Magic Cube. Then the fractional Fourier transforms (IDFRFT) of the interpolated sub-
rotated image is fed to the AES algorithm which is applied to the images. The complete transform orders of the employed FRFT
pixels of the image to encrypt the scrambled image. Finally, are used as the secret keys for the decryption of each sub-image.
experimental results and security analysis show that the proposed
image encryption scheme not only encrypts the picture to achieve In the second group, Zunino [6] used Peano-Hilbert curves to
perfect hiding, but the algorithm can also withstand exhaustive, provide pixel position permutations (transformation) to destroy
statistical and differential attacks. the spatial autocorrelation of an image. Zhang and Liu [7]
Keywords: Image encryption, AES, Magic cube, Image Entropy, proposed an image encryption algorithm based on a permutation-
Block Image Encryption, Correlation. diffusion construction and a skew tent map system. In their
proposed algorithm, the P-box is chosen as the size of the plain
image, which totally scrambles the pixels. To enhance the
1.Introduction security, the key stream in the diffusion step depends on both the
key and the plain image. Zhao and Chen [8] proposed to used
The security of images is of particular interest in this paper. ergodic matrixes for the shuffling and encryption of images. The
Traditional data encryption algorithms such as the private key authors analyzed the isomorphism relationship between ergodic
encryption standard (DES), public key standards such as Rivest matrices and permutations. Zhu et al. [9] proposed an innovative
Shamir Adleman (RSA), and the family of elliptic-curve-based permutation method to confuse and diffuse the grey-scale image
encryption (ECC), as well as the international data encryption at the bit level, which changes the position of each pixel and
algorithm (IDEA), may not be suitable for image encryption, changes its value. This algorithm also utilizes the Arnold cat map
especially for real-time applications[1]. In recent years, a number to permute the bits and a logistic map to additionally encrypt the
of encryption algorithms have been proposed to protect images. permutated image.
These encryption algorithms can be classified into several
categories such as value transformation[2-5], pixel position In the third category, Huang and Nien [10] proposed a new pixel
permutation [6-9], and chaotic systems [10-13]. shuffling scheme for colour image encryption which used chaotic
sequences created by chaotic systems as encryption codes. In
In the first group, Liu et al. [2] proposed an image encryption [11], a two-dimensional chaotic cat map was generalized to
algorithm based on an iterative random phase encoding in gyrator three-dimensions which was then utilized to design a rapid and
transform domains. Two-dimensional chaotic mapping is used to secure symmetric image encryption algorithm. This algorithm
create much random data for iterative random stage encoding. In uses the 3D cat map to scramble the locations and the values of
[3], a colour image encryption method using a discrete fractional the image pixels. Wang et al. [12] proposed an image encryption
random transform (DFRNT) and the Arnold transform (AT) in algorithm based on a simple perception and used a
the intensity-hue-saturation (IHS) colour space has been high-dimensional chaotic system in order to produce three sets of
suggested. Each colour space component is then encrypted pseudorandom sequences. The weight of each neuron of the
separately by different approaches. In [4], an image encryption perception is created in addition to a set of input signals, by use
algorithm based on the Arnold transform and the gyrator
of a nonlinear strategy. Recently, a new image encryption At the receiver side, the original image can be retrieved by an
algorithm combining permutation and diffusion has been inverse of the Rotation of the blocks. Mapping of the six sub-
proposed by Wang et al. [13]. The original image is divided into images on the magic cube faces is shown in Fig. 1
blocks and a spatiotemporal chaotic system is then employed to and a general block diagram of the rotating method is shown
create the pseudorandom sequences that are used for diffusing in Fig. 2.
and scrambling these blocks.
This paper proposes an encryption algorithm of an image based
on the rotation of a Magic Cube. The original image is divided
into six sub-images and these sub-images are divided amongst a
number of blocks and attached to the faces of a Magic Cube. The
faces are then scrambled using rotation of the Magic Cube. Then
the rotated image is fed to the AES algorithm which is applied to
the pixels of the image to encrypt the scrambled image.
Experimental results and security analysis show that the proposed
image encryption scheme not only encrypts the picture to achieve
perfect hiding, but the algorithm can also withstand exhaustive,
statistical and differential attacks.
2.The Proposed Technique
2.1 Description of the Rotation Algorithm
The rotation algorithm is presented below. It creates a
rotation table that will be used to build a newly rotated image
based on the idea of the magic cube. The rotation technique Fig. 1 Mapping of the six sub-images on the magic cube faces
works as follows:
Load the original image and resize the image to a size of M *
N so that we can partition or divide the resized image into six
sub-images of the same size and with no overlap.
The sub-images have the size (M/3) * (N/2). Mark the six
faces as Up (U), Front (F), Right (R), Left (L), Down (D) and
Back (B).
Load the six sub-images and divide into a number of blocks
with the same number of pixels. The image is decomposed
into blocks, each one containing a specific number of pixels.
Combine the hash function and secure key to build a rotation
table of encryption that will be used to rotate the rows and
columns of faces of the magic cube. The secret key and hash
function of this approach are used to play a main role in
building the rotated table, which will be used to generate the
rotated image. The rotation process refers to the operation of
dividing and rotating an arrangement of the original image.
The main idea is that an image can be encrypted by rotating
the rows and the columns of the magic cube faces (sub-
images) and not to change the positions of the blocks. By
rotating the rows a number of times depending on the Fig. 2 Diagram of the rotation algorithm
rotation table, and then the same number of times for the
columns for an arrangement of blocks, the image can be The rotation algorithm is presented below. It creates a
scrambled.
rotation table that will be utilized to build a newly
For better encryption, the block size should be small,
because in that way fewer pixels will be similar to their
encrypted image.
neighbours otherwise for an image with a high resolution, ALGORITHM CREATE_ROTATION_TABLE
the content of such an image may be predicted by an 1: Load Original Image
unauthorized user who can thus guess the image.
2: Input SecureKey
With a small block size, the correlation will be decreased and
3: Divide the Original Image into 6 sub-images
thus it becomes difficult to predict the value of any given
pixel from the values of its neighbours. 4: Calculate Width and Height of the sub-Images
The clear information present in an image is due to the 5:
relationship (correlation) among the image elements. This 5.1: N_Horizontal = Width /3 (each block contain 3
perceivable information can be reduced by decreasing the pixels * 3 pixels)
correlation among the image pixels using rotation or another 5.2: N_Column = Height /3 (each block contain
technique. In other words, the correlation between the blocks 3 pixels * 3 pixels)
of the image is decreased so as to provide a good level of
encryption of the image.
Rotate all the columns I in all the images F, R, B, L of
6: the magic cube (NumberOfRotation).
6.1: N_Column_Rotation Table (Index Of Columns Next I
in Rotation Table) = 128 Next J
6.2: If (N_Horizontal ≥ N_Column) then End Create_Rotation_Image
N_Horizontal_Rotation Table(Index Of Rows 9: Output: Rotation Image (Image Encryption)
in Rotation Table) = N_Horizontal
Else
N_Column_Rotation Table (Index Of Rows
in Rotation Table) = N_Column 2.2 Description of Integration Technique
7:
For I = 0 to N_Column_Rotation Table -1 The block-based rotation algorithm is based on the
For J = 0 to N_Horizontal_Rotation Table -1 integration of image rotation followed by the AES
Position Value = Hash Function algorithm. The rotation algorithm and the AES algorithm
(Index(I),Index(J), Secure Key) use the original image to generate three encrypted images;
Position Value to Assign location (a) a ciphered image using the AES algorithm, (b) a
I and J in the Rotation Table rotation image using a rotation process and (c) a rotation
Next J image encrypted using the AES algorithm.
Next I The correlation and entropy of the three images are
End Create_Rotation_Table calculated and evaluated against each other. This
8: Output: Rotation table technique aims at producing a good security level for the
encrypted images by decreasing the correlation among the
image pixels and increasing its entropy value. Image
ALGORITHM CREATE_ROTATION_IMAGE measurements (correlation, entropy and differential
(Encrypt) analysis) will be carried out on the original image and the
1: Load Original Image encrypted images with and without the rotation algorithm
2: Input SecureKey and the results will then be analyzed. The overview of the
3: Divide the Original Image into 6 sub-images (Faces of integration technique is presented in Fig. 3.
the magic cube)
4: Calculate Image Width and Height of sub-images
5:
5.1: N_Horizontal = Width /3
5.2: N_Column = Height /3
6: Divide each sub-image into blocks
(N_Horizontal*N_Column) (each block contain 3 pixels
*3
pixels).
7: L_Key = Length (SecureKey)
8:
For J = 0 to L_Key-1
8.1: (Rotation of The Rows Of Images that are
attached to the faces of the magic cube F,
U, B, D) ndexOfColumnsInRotationTable=
Int (SecureKey( J ))
For I = 0 to N_Horizontal -1
NumberOfRotation = RotationTable(I,
IndexOfColumnsInRotationTable )
Rotate all the rows I in all the images F,
U, B, D of the magic cube
(NumberOfRotation).
Next I
8.2: (Rotation of The Columns Of Images that are
attached to the faces of the magic cube F, R, B, L)
IndexOfColumnsInRotationTable= Int
(SecureKey( J ))
For I = 0 to N_Column -1 Fig. 3. Diagram of the proposed technique
NumberOfRotation = RotationTable(I,
Rotation algorithm AES algorithm Proposed technique
IndexOfColumnsInRotationTable )
distributed, and significantly different from the respective
3.Experimental Details and Results histograms of the original images.
A good quality encryption algorithm should be strong
against all types of attack, including statistical and brute
force attacks. Some experiments are given in this section
to demonstrate the efficiency of the proposed technique. In
this section, the proposed technique is applied on an image
that has 300 * 300 pixels and four selected different cases
are analyzed in detail to test the performance of the
proposed technique. The number of blocks and the block
sizes in each case are shown in Table 1. (a) (b)
Table 1 Different cases of number of blocks and the number of pixels
Case number Number of Block size
blocks
1 150 * 150 2 Pixels * 2 Pixels
2 100 * 100 3 Pixels * 3 Pixels
3 60 * 60 5 Pixels * 5 Pixels
4 50 * 50 6 Pixels * 6 Pixels (c) (d)
The rotation algorithm and the AES algorithm are used on
the plain image to generate three encrypted images (a) a
ciphered image using the AES algorithm, (b) a rotation
image using the rotation process and (c) a rotation image
encrypted using the AES algorithm. The correlation and
entropy of the three images are calculated and evaluated.
2.3 Statistical Analysis (a) (b)
In order to resist statistical attacks, the encrypted images
should possess certain random properties. To prove the
robustness of the proposed algorithm, a statistical analysis
has been performed by calculating the histograms, the
entropy, the correlations and differential analysis for the
plain image and the encrypted image. Different images
have been tested, and it has been determined that the (c) (d)
intensity values are good. Fig. 4 : (a) Original Image (b) Histogram of Original Image (c) Encrypted
Image (d) Histogram of Encrypted Image
2.3.1 Histogram Analysis
2.3.2 Correlation of two adjacent pixels
An image histogram is a commonly used method of
analysis in image processing and data mining applications. A correlation is a statistical measure of security that
The advantage of a histogram is that it shows the shape of expresses a degree of relationship between two adjacent
the distribution for a large set of data. Thus, an image pixels in an image or a degree of association between
histogram illustrates how the pixels in an image are two adjacent pixels in an image. The aim of correlation
distributed by graphing the number of pixels at each colour measures is to keep the amount of redundant
intensity level. It is important to ensure that the encrypted information available in the encrypted image as low as
and original images do not have any statistical similarities. possible[15, 16].
The histogram analysis clarifies how pixels in an image
are distributed by plotting the number of pixels at each In general, if the correlation coefficient equals zero or is
intensity level. very near to zero, then the original image and its encrypted
version are totally different. It can be inferred that the
The experimental results of the plain image and its encrypted image has no features and is highly independent
corresponding cipher image and their histograms are of the original image. If the correlation coefficient is equal
shown in Fig. 4. The histogram of each plain image to -1, that means the encrypted image is a negative of the
illustrates how the pixels are distributed by graphing the original image.
number of pixels at every grey level [14]. It is clear that
the histogram of the encrypted image is nearly uniformly
In the experiments results, 2000 pairs of two adjacent distribution of two diagonally adjacent pixels in the encrypted image. (g)
distribution of two anti-diagonally adjacent pixels in the original image.
pixels are randomly selected. Fig. 5 shows the distribution
(h) Distribution of two anti-diagonally adjacent pixels in the encrypted
of two adjacent pixels in the original image and the image.
encrypted-image. There is very good correlation between
adjacent pixels in the image data [17, 18], while there is 2.3.3 Information Entropy
only a small correlation between adjacent pixels in the
encrypted image. Equation (1) is used to study the Information theory is the mathematical theory of data
correlation between two adjacent pixels in the horizontal, communication and storage founded in 1949 by Shannon
vertical, diagonal and anti-diagonal orientations: [19]. Information entropy is defined to express the degree
of uncertainties in the system. It is well known that the
∑ ( ) ∑ ∑ entropy H(m) of a message source m can be calculated as:
(1)
√( ∑ – (∑ ) ) ( ∑ – (∑ ) )
( ) ∑ ( ) (2)
( )
where x and y are the intensity values of two neighbouring where P (mi ) represents the probability of symbol mi and
pixels in the image and N is the number of adjacent pixels the entropy is expressed in bits. Let us suppose that the
selected from the image to calculate the correlation. source emits 28 symbols with equal probability, i.e., 1 2 2 8
Results for the correlation coefficients of two adjacent m = {m ,m ,...,m }. Truly random source entropy is equal
pixels are shown in Tables 2, 3, 4 and 5. to 8. Actually, given that a practical information source
seldom generates random messages, in general its entropy
value is smaller than the ideal. However, when the
messages are encrypted, their entropy should ideally be 8.
If the output of such a cipher emits symbols with an
entropy of less than 8, there exists a certain degree of
predictability which threatens its security. Results for the
entropy are shown in Tables 2, 3, 4 and 5.
Case 1: The image is divided into 6 pixels * 6 pixels in
(a) (b)
each block. Figure 6 shows the image cases:
(c) (d)
(a) (b)
(e) (f)
(c) (d)
Fig. 6. (a) Original image. (b) Encrypted image using AES (c) Rotation
image. (d) Encrypted image using integration technique
Table 2. Correlation of Two Pixels and Entropy value
Correlation Analysis
(g) (h) Entropy
adjacent pixels
value
Fig.5: Correlation of two adjacent pixels: (a) distribution of two Image Horizontal Vertical Diagonal Anti-
horizontally adjacent pixels in the original image, (b) distribution of two Diagonal
horizontally adjacent pixels in the encrypted image (i.e., cipher image); A 0.9951 5.99900 5.99.0 5.99.0 7.0443
(c) distribution of two vertically adjacent pixels in the original image, (d)
distribution of two vertically adjacent pixels in the encrypted image. (e) B -5.50000 -0.0476 -0.0208 -0.0317 7.9256
distribution of two diagonally adjacent pixels in the original image. (f) C 0.7540 0.7790 0.6120 0.6389 7.1338
D -0.0456 -0.0478 -0.0253 -0.0319 7.9417
Case 2: The image is divided into 5 pixels * 5 pixels in Table 4. Correlation of Two Pixels and Entropy value
each block. Fig. 7 shows the image cases:
Correlation Analysis
Entropy
adjacent pixels value
Image
Horizontal Vertical Diagonal Anti-
Diagonal
A 0.9951 5.99900 5.99.0 5.99.0 7.0443
B -5.50000 -0.0476 -0.0208 -0.0317 7.9256
C 0.5920 0.5887 0.3820 0.3898 7.1766
(a) (b)
D -0.0449 -0.0520 -0.0433 -0.0388 7.9448
Case 4: The image is divided into 2 pixels * 2 pixels in
each block. Figure 9 shows the image cases:
(c) (d)
Figure 7. (a) Original image. (b) Encrypted image using AES (c) Rotation
image. (d) Encrypted image using integration technique.
Table 3. Correlation of Two Pixels and Entropy value
(a) (b)
Correlation Analysis
adjacent pixels Entropy
value
Image Horizontal Vertical Diagonal Anti-
Diagonal
A 0.9951 5.99900 5.99.0 5.99.0 7.0443
B -5.5000 -0.0476 -0.0208 -0.0317 7.9256
C 0.7420 0.7577 0.5920 0.5998 7.1538
(c) (d)
D -0.0486 -0.0488 -0.0353 -0.0386 7.9438
Fig. 9. (a) Original image. (b) Encrypted image using AES (c) Rotation
image. (d) Encrypted image using integration technique.
Table 5. Correlation of Two Pixels and Entropy value
Case 3: The image is divided into 3 pixels * 3 pixels in Correlation Analysis
each block. Figure 8 shows the image cases: adjacent pixels
Entropy
value
Image
Horizontal Vertical Diagonal Anti-
Diagonal
A 0.9951 5.99900 5.99.0 5.99.0 7.0443
B -5.50000 -0.0476 -0.0208 -0.0317 7.9256
C 0.5812 0.5773 0.3820 0.3898 7.1766
D -0.0449 -0.0520 -0.0433 -0.0388 7.9448
(a) (b)
4.Conclusion
In this paper, a new image encryption algorithm is
proposed. This algorithm is based on the theory of the
Magic cube to shuffle the image blocks. To confuse the
relationship between the plain image and the encrypted
image, the rotated image is fed into an AES algorithm
(c) (d) which is applied to each pixel of the image to encrypt the
image even further. Experimental tests have been carried
Fig. 8. (a) Original image. (b) Encrypted image using AES (c) Rotation
image. (d) Encrypted image using integration technique. out utilising detailed numerical analysis which shows the
strength of the proposed algorithm against several types of
attack such as statistical and differential attacks. The
proposed technique presented an inverse relationship
existing between the number of blocks and correlation. 16. Jolfaei, A. and A. Mirghadri, Survey: image encryption using
There exists a direct relationship between the number of Salsa20. International Journal of Computer Science Issues,
blocks and entropy. This technique is expected to show 2010. 7(5): p. 213-220.
good performance, uniform distribution in a histogram, a 17. H. El-din. H. Ahmed, H.M.K., O. S. Farag Allah, Encryption
quality analysis of the RC5 block cipher algorithm for digital
low correlation and high entropy. Moreover, performance images. Optical Engineering, 2006. 45( 10).
assessment tests demonstrate that the proposed image 18. Ibrahim S I Abuhaiba and M.A.S. Hassan, Image Encryption
encryption algorithm is highly secure. It is also able to Using Differential Evolution Approach in Frequency
encrypt large data sets efficiently. The proposed method is Domain. Signal & Image Processing : An International
expected to be useful for real time image encryption and Journal(SIPIJ), 2011. 2, No.1: p. 51-69.
transmission applications. 19. Shannon, C.E., Communication Theory of Secrecy Systems.
Bell Syst Tech J. 1949.
Acknowledgments
This paper is part of PhD work in the Faculty of
Information and Communication Technology, Universiti Ahmed Bashir Abugharsa received BSc in Computer Science
from Misurata University in Misurata, Libya, MSc from Universiti
Teknikal Malaysia Melaka (UTeM). Tun Abd Razak, Faculty of Information Technology in January
2011 in Kuala Lumpur, Malaysia and currently enrolled in the
References PhD program in Computer Science in the Universiti Teknikal
Malaysia Melaka (UTeM) in Malaka, Malaysia.
1. Loukhaoukha, K., J.Y. Chouinard, and A. Berdai, A Secure
Image Encryption Algorithm Based on Rubik&# 39; s Cube Dr. ABD. SAMAD BIN HASAN BASARI received BSc in
Principle. Journal of Electrical and Computer Engineering, Mathematics from Universiti Kebangsaan Malaysia in 1998,
Master in IT-Education from Universiti Universiti Teknologi
2012. 2012.
Malaysia in 2002, PhD in ICT from Universiti Teknikal Malaysia
2. Liu, Z., et al., Image encryption scheme by using iterative Melaka in 2009 and currently SENIOR Department of Industrial
random phase encoding in gyrator transform domains. Computing Faculty of Information and Communication
Optics and Lasers in Engineering, 2011. 49(4): p. 542-546. Technology, Universiti Teknikal Malaysia Melaka (UTeM).
3. Guo, Q., Z. Liu, and S. Liu, Color image encryption by using
Arnold and discrete fractional random transforms in IHS
Hamida Mohamed Almangush received BSc in Computer
space. Optics and Lasers in Engineering, 2010. 48(12): p. Science from Misurata University in Misurata, Libya, MSc from
1174-1181. Universiti Tun Abd Razak, Faculty of Information Technology in
4. Liu, Z., et al., Image encryption by using gyrator transform January 2011 in Kuala Lumpur, Malaysia and currently enrolled
and Arnold transform. Journal of Electronic Imaging, 2011. in the PhD program in Computer Science in the Universiti
20: p. 013020. Teknikal Malaysia Melaka (UTeM) in Malaka, Malaysia.
5. R. Tao, X. Y. Meng, and Y.Wang. Image
encryptionwithmultiorders of fractional fourier transforms.
in Information Forensics and Security. 2010: IEEE
Transactions on Image Processing
6. Zunino, R., Fractal circuit layout for spatial decorrelation of
images. Electronics Letters, 1998. 34(20): p. 1929-1930.
7. Zhang, G. and Q. Liu, A novel image encryption method
based on total shuffling scheme. Optics Communications,
2011.
8. Zhao, X. and C. Gang. Ergodic matrix in image encryption.
2002.
9. Zhu, Z., et al., A chaos-based symmetric image encryption
scheme using a bit-level permutation. Information Sciences,
2011. 181(6): p. 1171-1186.
10. Huang, C. and H. Nien, Multi chaotic systems based pixel
shuffle for image encryption. Optics Communications, 2009.
282(11): p. 2123-2127.
11. Wang, K., et al., On the security of 3D Cat map based
symmetric image encryption scheme. Physics Letters A,
2005. 343(6): p. 432-439.
12. Wang, X.Y., et al., A chaotic image encryption algorithm
based on perceptron model. Nonlinear Dynamics, 2010.
62(3): p. 615-621.
13. Wang, Y., et al., A new chaos-based fast image encryption
algorithm. Applied Soft Computing, 2011. 11(1): p. 514-522.
14. Abderrahim, N.W., F.Z. Benmansour, and O. Seddiki,
Integration of chaotic sequences uniformly distributed in a
new image encryption algorithm. 2012.
15. Burger, W. and M. Burge, Digital image processing: an
algorithmic introduction using Java. 2008: Springer-Verlag
New York Inc.