# A Hash-Based Fast Image Encryption Algorithm

Authors: Ruifeng Han
Journal: Wireless Communications and Mobile Computing
 (2022)

---

## Abstract

Many specialists and academics have recently become interested in the security of digital images in applications for the Internet of Things. Hash-based digital image encryption algorithms with high unified average changing intensity (UACI>30.96 percent) and only one pixel difference from the plain image would therefore adjust plenty of the pixels in the cipher image and have indeed been suggested to maintain the protection of images in the Internet of Things (NPCR>98.77 percent). Theoretical study and simulation results show that the suggested approach can fix these issues while retaining all the advantages of the original. The proposed image encryption algorithm has important application value for strengthening the security of the Internet of Things.


---

## Body

## 1. Introduction

With the continuous development of information technology and computer processing power, cryptography has also been extended. Because the network environment, especially Internet of Things environment is vulnerable to attacks, and digital images contain redundant information, which is closely related to personal privacy, once it is leaked, it is likely to be personally threatened and even affect commercial secrets and national security. Many algorithms exclusively handle with digital encrypted images or text encryption, respectively. Several algorithms, nevertheless, integrate these two tasks. Passwords are simpler and easier for people to recognize than pseudorandom numbers or a long string of codes, making it more practical and appropriate to password-protect digital photographs [1]. Liu and Tan put forth a plan that uses 1D SHA-2 algorithms combined with password protection to encrypt digital images with compound forward transform [2].


## 2. Defect Analysis of the Original Algorithm

### 2.1. Lack of Connectivity between Pixels during Encryption

During the encryption of the original image, the key stream generation step and there really is no relationship either between pixel intensity, and indeed, the postprocessing phase solely affects each pixel inside a one-to-one relationship. This characteristic may expose it to selected attacks [3]. An attacker can do this by encrypting only two images that differ by only one pixel. The plain picture and the cipher image could both be found by an opponent because the two encrypted images just vary with one pixel from one another. Figure 1 illustrates an illustration of a 16×16 image. Following encrypted data, point (1, 2) in the original image is transferred to point (12, 5). An opponent can find the permutation rules for a pixel by performing this method again for each pixel in the original image. This is the same as disclosing a fresh random map during postprocessing [4].Figure 1
Mapping process.


### 2.2. The Only Dependency of the Key Stream

We discover that the participant’s password is completely dependent on the secret key during the encryption step of the original technique. The associated stream usually stays the same as long as the cipher is unmodified, regardless of whether this is used mostly for XOR with the original picture or for a postprocessing step. A known-plaintext assault on the original algorithm is hence inevitable. The following formulas are used to express the random keyK1,K2,⋯,KM×N, KMN that the adversary could retrieve if they are given a pair of pure image needs to set G=G1,G2,⋯,GM×N and a placed of cipher maps C=C1,C2,⋯,CM×N.
(1)Ki=Ci⊕Gi,1<i≤8×M×N.The permutation rules for pixels are recovered when used with the chosen-plaintext attack previously discussed. Understanding the key stream produced by a specific key is identical to actually having that key. The equivalent normal image may be retrieved instantly for whichever cipher image encoded with almost the same key.


### 2.3. Attack Simulation

Let us say there is a password image but no one knows the key. An attacker could trick the encryption system by feeding it a black image (every pixel inside the encrypted image equals 0) to get the cipher imageB. B is definitely a different key stream. We could derive the replacement rule, designated by M, using the procedure outlined in Section 2.1. Apply rule M on the replaced key stream to undo it. We could create a new key stream that seems to be identical to the key stream obtained by doing an XOR operation with the original image prior to replacement. There seem to be two procedures required to obtain the original image for encrypted images. Flip the encrypted image using rule M firstly and afterwards XOR the new key stream after that. The outcome is the accurate normal picture. Throughout Figure 2, the attack procedure is depicted.Figure 2
Attack process.
(a)(b)(c)(d)


## 2.1. Lack of Connectivity between Pixels during Encryption

During the encryption of the original image, the key stream generation step and there really is no relationship either between pixel intensity, and indeed, the postprocessing phase solely affects each pixel inside a one-to-one relationship. This characteristic may expose it to selected attacks [3]. An attacker can do this by encrypting only two images that differ by only one pixel. The plain picture and the cipher image could both be found by an opponent because the two encrypted images just vary with one pixel from one another. Figure 1 illustrates an illustration of a 16×16 image. Following encrypted data, point (1, 2) in the original image is transferred to point (12, 5). An opponent can find the permutation rules for a pixel by performing this method again for each pixel in the original image. This is the same as disclosing a fresh random map during postprocessing [4].Figure 1
Mapping process.


## 2.2. The Only Dependency of the Key Stream

We discover that the participant’s password is completely dependent on the secret key during the encryption step of the original technique. The associated stream usually stays the same as long as the cipher is unmodified, regardless of whether this is used mostly for XOR with the original picture or for a postprocessing step. A known-plaintext assault on the original algorithm is hence inevitable. The following formulas are used to express the random keyK1,K2,⋯,KM×N, KMN that the adversary could retrieve if they are given a pair of pure image needs to set G=G1,G2,⋯,GM×N and a placed of cipher maps C=C1,C2,⋯,CM×N.
(1)Ki=Ci⊕Gi,1<i≤8×M×N.The permutation rules for pixels are recovered when used with the chosen-plaintext attack previously discussed. Understanding the key stream produced by a specific key is identical to actually having that key. The equivalent normal image may be retrieved instantly for whichever cipher image encoded with almost the same key.


## 2.3. Attack Simulation

Let us say there is a password image but no one knows the key. An attacker could trick the encryption system by feeding it a black image (every pixel inside the encrypted image equals 0) to get the cipher imageB. B is definitely a different key stream. We could derive the replacement rule, designated by M, using the procedure outlined in Section 2.1. Apply rule M on the replaced key stream to undo it. We could create a new key stream that seems to be identical to the key stream obtained by doing an XOR operation with the original image prior to replacement. There seem to be two procedures required to obtain the original image for encrypted images. Flip the encrypted image using rule M firstly and afterwards XOR the new key stream after that. The outcome is the accurate normal picture. Throughout Figure 2, the attack procedure is depicted.Figure 2
Attack process.
(a)(b)(c)(d)


## 3. Improved Algorithm

In order to overcome the above potential defects, the following improved algorithm is proposed:(1)
For convenience, the initial image post-processing step is modified by us to the following equation, defined as ACM; this includes the three variablesa, b, and k. To create the three variables that will substitute the efficient algorithm, we utilize Ki=HHKey. In our enhanced algorithm, however, k rounds of operations are required in the encryption/decryption stage. On each turn, swap positions between (0,0) and (1,1). Each round takes turns.(2)xn+1yn+1=ab+1ab1xnynmod1,a,b∈N(2)
The improved algorithm is performed by splitting the image into two equal pieces and then independently encrypting each piece. The key stream is determined by the user key and original image features [5, 6]. In other words, when the same key is used, different images are encrypted with the key stream as a variable; it aids in preventing selected and known-plaintext attacks on the encryption algorithm


### 3.1. Encryption

(1)
Identical to steps one and two of the initial step(2)
Generate a new key streamK0 with image features. First, the original image is divided into two equal parts L0 and R0 in the vertical direction, and the two parts are encrypted, respectively, and the formula is as follows. First, encrypt the information of R0 using L0 to R1; the right part has been encrypted. Then, L0 is encrypted to L1 using R1’s information(3)
Finally, to acquire the cipher picture, combine the 2 encrypted componentsL1 and R1(3)R1=CompleximresizeK′⊕gL0,M,N2,′nearest′⊕R0,L1=CompleximresizeK′⊕gR1,M,N2,′nearest′⊕L0.L0 and R0 throughout the example above stand for the left and right sides of something like the pure picture, while L1 and R1 stand for the left and right sides of the cipher image, gL0 and gR1 represent the average gray value of L0 and R1 which is of variable size, (∙, [M, N/2], “nearest”) represents the expansion operation, the “nearest” method is used to the process of enlarging an image to M rows, and N/2 column is known as cosine similarity interpolation. The number of the pixel to which this pertinent is allocated to the output pixel; additional pixels are not taken into account. The compound transformation in the initial encryption is represented by complex(∙)
(4)
The postprocessing step is ACM(5)
Encrypted imagesFigure3 depicts the encryption process algorithm. Figure 4 depicts the key stream creation algorithm.Figure 3
Encryption process algorithm.Figure 4
Key stream generation algorithm.


### 3.2. Decryption

To obtain the XOR key stream, firstly invert the ACM.Encrypt the XOR key stream to produce a plain picture next.L1 to L0 first were encrypted using R1’s data. Next, as stated in the following expression, utilize the data from L0 to decode R1 to R0. L0 and R0 are the left and right halves of the plain image, whereas L1 and R1 are the left and right halves of the encrypted image.
(4)L0=L1⊕CompleximresizeK′⊕gR1,M,N2,′nearest′,R0=R1⊕CompleximresizeK′⊕gL0,M,N2,′nearest′.Finally, the two decrypted partsL0 and R0 are connected together to obtain a decrypted image.


## 3.1. Encryption

(1)
Identical to steps one and two of the initial step(2)
Generate a new key streamK0 with image features. First, the original image is divided into two equal parts L0 and R0 in the vertical direction, and the two parts are encrypted, respectively, and the formula is as follows. First, encrypt the information of R0 using L0 to R1; the right part has been encrypted. Then, L0 is encrypted to L1 using R1’s information(3)
Finally, to acquire the cipher picture, combine the 2 encrypted componentsL1 and R1(3)R1=CompleximresizeK′⊕gL0,M,N2,′nearest′⊕R0,L1=CompleximresizeK′⊕gR1,M,N2,′nearest′⊕L0.L0 and R0 throughout the example above stand for the left and right sides of something like the pure picture, while L1 and R1 stand for the left and right sides of the cipher image, gL0 and gR1 represent the average gray value of L0 and R1 which is of variable size, (∙, [M, N/2], “nearest”) represents the expansion operation, the “nearest” method is used to the process of enlarging an image to M rows, and N/2 column is known as cosine similarity interpolation. The number of the pixel to which this pertinent is allocated to the output pixel; additional pixels are not taken into account. The compound transformation in the initial encryption is represented by complex(∙)
(4)
The postprocessing step is ACM(5)
Encrypted imagesFigure3 depicts the encryption process algorithm. Figure 4 depicts the key stream creation algorithm.Figure 3
Encryption process algorithm.Figure 4
Key stream generation algorithm.


## 3.2. Decryption

To obtain the XOR key stream, firstly invert the ACM.Encrypt the XOR key stream to produce a plain picture next.L1 to L0 first were encrypted using R1’s data. Next, as stated in the following expression, utilize the data from L0 to decode R1 to R0. L0 and R0 are the left and right halves of the plain image, whereas L1 and R1 are the left and right halves of the encrypted image.
(4)L0=L1⊕CompleximresizeK′⊕gR1,M,N2,′nearest′,R0=R1⊕CompleximresizeK′⊕gL0,M,N2,′nearest′.Finally, the two decrypted partsL0 and R0 are connected together to obtain a decrypted image.


## 4. Performance Analysis

In this section, a256×256 Lena gray image [7] is selected to conduct comparative experiments.All experiments were performed using MATLAB 7.9 on a personal computer (PC) which has a 250 GB hard drive, a 2.0 GHz Intel dual-core microprocessor, and 1.99 GB of storage [8].


### 4.1. Histogram of Encrypted Image

Every gray level’s frequency is shown in the graph, and that every gray level mainly related to the digital image [9]. The histograms of the original and encrypted images are seen in Figure 5.Figure 5
Histogram of original image and password image.
(a)
Original image(b)
Histogram of original image(c)
Encrypted image(d)
Histogram of encrypted imageThe graph of the password picture is quite homogeneous and distinct from the actual picture, as shown in the figure.


### 4.2. Correlation of Two Adjacent Pixels

The correlation of test image pixels includes horizontal correlation and diagonal correlation: first, in the picture, 2500 pairs of adjacent pixels are chosen at random, and then, the correlation coefficient is calculated by(5)rxy=covx,yDx×Dy,(6)covx,y=1N∑i=1Nxi,(7)Dx=1N∑i=1Nxi−Ex2,where the gray scale values of the adjacent image pixels are represented byx and y.Figure6 depicts, correspondingly, the horizontal, vertical, and diagonal correlations between the two images. Table 1 displays the findings of the regression analysis of adjacent pixels.Figure 6
Correlation of two horizontally adjacent pixels.
(a)(b)(c)(d)(e)(f)Table 1
Correlation coefficient of two adjacent pixels.
Normal imagePassword imageLevel0.94310.0089Vertical0.9725-0.0215Diagonal0.9264-0.0074


### 4.3. Sensitivity Analysis

Often, an adversary might alter the encrypted image slightly in order to observe the change in results. In doing so, meaningful relationships between plain images and cryptographic images can be found. This is called a differential attack.


#### 4.3.1. NPCR and UACI Analyses

But only when the pictures vary by something like a single pixel, NPCR denotes the rate of difference in the frequency of pixels inside an encryption algorithm. The unified average intensity of change (UACI) metric calculates the average brightness of the variation between the two images. NPCR and UACI both rely on slight adjustments to the two images while maintaining the same key. In reference [10], the original image and key of the NPCR calculated by the author have changed by one bit.Suppose there are two encrypted pictures,C1 and C2, which normal control pictures vary by just one pixel. The gray scale values of the encrypted images C1 and C2 are designated as C1i,j and C2i,j, accordingly, in the i-th row and j-th column.The definitions of NPCR and UACI are(8)NPCR=∑i=1M∑j=1NM×N×100%,UACI=∑i=1M∑j=1NCii,j−C2i,jM×N×256×100%.The sizes of the picture areM and N, correspondingly.For our instance, the key “SecureMePlease!” has been used, and the chosen pixel is the position (1,2) of the image pixels. Its number is altered from (10100011)2 to (10100010)2. NPCR and UACI are therefore reported in Table2.Table 2
NPCR and UACI analyses.
Normal imagePassword imageNPCR0.0015%98.7778%UACI0.0000%30.9639%Table2 demonstrates how much greater our revised technique is programmatically than the original method in sensitivity.The responsiveness to the actual picture is quite low in the original method. The whole key picture in the256×256 sample provided has only been modified by roughly 0.0015 percent. The UACI is around 0 [11]. Experiments show that encrypted images are vulnerable to plaintext and known-plaintext attacks.Consequently, it is evident that our enhanced approach fixes the old system’s flaw of being blind to minute alterations in planar images. The encrypted picture’s pixels shift whenever a single pixel in the original picture changes (NPCR>98.77%), and the universal mean shift intensity increases (UACI>30.96%). The results demonstrate that the effectiveness is satisfactory.


#### 4.3.2. Key Sensitivity Test

Crucial sensitivity is the pace at which a cryptographic picture’s pixel count changes even though only one piece of the password is changed. The usual image should first be encrypted with the testing password “SecureMePlease!” before the least-valid password is changed to “SecureMePlease.” and the identical image is encrypted. Consider the various password photos once more.The outcome is in regard to pixel gray levels, the encrypted image is completely different with a slight difference in the key (as shown in Figure7). Table 3 displays the outcomes of the encryption with different keys, with an average rate of change as high as 99.323%.Figure 7
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Encrypted image: key = “SecureMePlease!”(d)
Difference imageTable 3
Rate of change.
Original keyNew keyChange rateSecureMePlease!SecureMePlease.99.600%secureMePlease!99.161%SecuremePlease!99.245%SecureMePlease99.295%Also, if the image is encrypted with a key and decrypted with another, simply modified key, the decryption fails. Figure8 demonstrates how photos encrypted using the “SecureMePlease!” password cannot be properly decoded with the “SecureMePlease” password.Figure 8
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Decrypted image: key = “SecureMePlease!”(d)
Decrypted image: key = “SecureMePlease!”


### 4.4. Other Security Analysis

#### 4.4.1. Resist Plaintext Attack

We may observe a significant change at the crucial stream creation when evaluating the original method with the revised approach. The user’s passcode is the single factor that determines how the key stream is utilized in the original file, whether it is for an XOR operation with the actual picture or for postprocessing. It is separated from typical visuals. The key stream in our enhanced technique is based on the original picture’s properties as well as the user’s passcode. That is, although just use the same passcode, if various photos are encoded, the crucial stream of the XOR stage is unpredictable. This person assists with encrypted photographs defend against selected plaintext attacks and known plaintext attacks.Also, a cryptanalyst sending a dark image through into encryption method seems to have no impact on the operation because the key stream is varied when encrypting various images with the same cipher. The “chosen plain text assault” discussed above can be eliminated by our enhanced algorithm.


#### 4.4.2. Diffusion and Chaos

Obfuscation and diffusion are two characteristics of secure cryptographic procedures that were first established by Claude Shannon in the field of cryptography. NPCR demonstrates that when just one pixel of the plaintext is altered, nearly every pixel in the cryptographic picture is altered, as illustrated in Section4.3.1 (NPCR>98.77 percent). The revised algorithm’s diffusion characteristics are excellent.Through the correlation analysis of the gray histogram and adjacent pixels, the proposed improved algorithm has good chaos.


#### 4.4.3. Brute Force Attack

The suggested enhanced algorithm depends on the required space length and critical sensitivities for brute force attack evaluation.Essential space: the SHA-2 method and the FFT-DCT composite transform are irreparable processes, as was already stated; in addition, ARM will arrange the pixels, which is very secure for common commercial applicationsKey sensitivity: as shown in Figures7 and 8, even a small key change causes almost all pixels to change the corresponding cryptographic imageTherefore, our algorithm is highly resistant to brute force attacks.


### 4.5. Comparison of Similar Algorithms

The algorithm proposed in this paper has superiority by comparing and analyzing the algorithm of literature [12] and literature [13]. Reference [12] suggested a Feistel network-based picture encryption technique, which has high security and can be comparable to the algorithm in this paper, but there is a gap with this paper in terms of sensitivity. This paper also introduces in Section 4.3. The algorithm in this paper Fewer iteration rounds are required.In addition, although the literature [13] has been improved, the encryption speed of the algorithm in this paper is significantly higher than that of the literature [13]. Table 4 shows the image encryption algorithms proposed in this paper, literature [12] and literature [13]. The time required to encrypt the same image, it can be seen that the encryption speed of this paper is the fastest that is because the literature [12] uses a large number of iterations, resulting in a slow operation, while the literature [13] is because there are too many rounds. This results in increased computation time, which in turn slows down encryption.Table 4
Encryption time of three encryption algorithms.
Encryption algorithmImage sizeEncryption timeLiterature [12]90∗1802.13Literature [13]128∗1281.24The algorithm in this paper128∗1280.15


## 4.1. Histogram of Encrypted Image

Every gray level’s frequency is shown in the graph, and that every gray level mainly related to the digital image [9]. The histograms of the original and encrypted images are seen in Figure 5.Figure 5
Histogram of original image and password image.
(a)
Original image(b)
Histogram of original image(c)
Encrypted image(d)
Histogram of encrypted imageThe graph of the password picture is quite homogeneous and distinct from the actual picture, as shown in the figure.


## 4.2. Correlation of Two Adjacent Pixels

The correlation of test image pixels includes horizontal correlation and diagonal correlation: first, in the picture, 2500 pairs of adjacent pixels are chosen at random, and then, the correlation coefficient is calculated by(5)rxy=covx,yDx×Dy,(6)covx,y=1N∑i=1Nxi,(7)Dx=1N∑i=1Nxi−Ex2,where the gray scale values of the adjacent image pixels are represented byx and y.Figure6 depicts, correspondingly, the horizontal, vertical, and diagonal correlations between the two images. Table 1 displays the findings of the regression analysis of adjacent pixels.Figure 6
Correlation of two horizontally adjacent pixels.
(a)(b)(c)(d)(e)(f)Table 1
Correlation coefficient of two adjacent pixels.
Normal imagePassword imageLevel0.94310.0089Vertical0.9725-0.0215Diagonal0.9264-0.0074


## 4.3. Sensitivity Analysis

Often, an adversary might alter the encrypted image slightly in order to observe the change in results. In doing so, meaningful relationships between plain images and cryptographic images can be found. This is called a differential attack.


### 4.3.1. NPCR and UACI Analyses

But only when the pictures vary by something like a single pixel, NPCR denotes the rate of difference in the frequency of pixels inside an encryption algorithm. The unified average intensity of change (UACI) metric calculates the average brightness of the variation between the two images. NPCR and UACI both rely on slight adjustments to the two images while maintaining the same key. In reference [10], the original image and key of the NPCR calculated by the author have changed by one bit.Suppose there are two encrypted pictures,C1 and C2, which normal control pictures vary by just one pixel. The gray scale values of the encrypted images C1 and C2 are designated as C1i,j and C2i,j, accordingly, in the i-th row and j-th column.The definitions of NPCR and UACI are(8)NPCR=∑i=1M∑j=1NM×N×100%,UACI=∑i=1M∑j=1NCii,j−C2i,jM×N×256×100%.The sizes of the picture areM and N, correspondingly.For our instance, the key “SecureMePlease!” has been used, and the chosen pixel is the position (1,2) of the image pixels. Its number is altered from (10100011)2 to (10100010)2. NPCR and UACI are therefore reported in Table2.Table 2
NPCR and UACI analyses.
Normal imagePassword imageNPCR0.0015%98.7778%UACI0.0000%30.9639%Table2 demonstrates how much greater our revised technique is programmatically than the original method in sensitivity.The responsiveness to the actual picture is quite low in the original method. The whole key picture in the256×256 sample provided has only been modified by roughly 0.0015 percent. The UACI is around 0 [11]. Experiments show that encrypted images are vulnerable to plaintext and known-plaintext attacks.Consequently, it is evident that our enhanced approach fixes the old system’s flaw of being blind to minute alterations in planar images. The encrypted picture’s pixels shift whenever a single pixel in the original picture changes (NPCR>98.77%), and the universal mean shift intensity increases (UACI>30.96%). The results demonstrate that the effectiveness is satisfactory.


### 4.3.2. Key Sensitivity Test

Crucial sensitivity is the pace at which a cryptographic picture’s pixel count changes even though only one piece of the password is changed. The usual image should first be encrypted with the testing password “SecureMePlease!” before the least-valid password is changed to “SecureMePlease.” and the identical image is encrypted. Consider the various password photos once more.The outcome is in regard to pixel gray levels, the encrypted image is completely different with a slight difference in the key (as shown in Figure7). Table 3 displays the outcomes of the encryption with different keys, with an average rate of change as high as 99.323%.Figure 7
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Encrypted image: key = “SecureMePlease!”(d)
Difference imageTable 3
Rate of change.
Original keyNew keyChange rateSecureMePlease!SecureMePlease.99.600%secureMePlease!99.161%SecuremePlease!99.245%SecureMePlease99.295%Also, if the image is encrypted with a key and decrypted with another, simply modified key, the decryption fails. Figure8 demonstrates how photos encrypted using the “SecureMePlease!” password cannot be properly decoded with the “SecureMePlease” password.Figure 8
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Decrypted image: key = “SecureMePlease!”(d)
Decrypted image: key = “SecureMePlease!”


## 4.3.1. NPCR and UACI Analyses

But only when the pictures vary by something like a single pixel, NPCR denotes the rate of difference in the frequency of pixels inside an encryption algorithm. The unified average intensity of change (UACI) metric calculates the average brightness of the variation between the two images. NPCR and UACI both rely on slight adjustments to the two images while maintaining the same key. In reference [10], the original image and key of the NPCR calculated by the author have changed by one bit.Suppose there are two encrypted pictures,C1 and C2, which normal control pictures vary by just one pixel. The gray scale values of the encrypted images C1 and C2 are designated as C1i,j and C2i,j, accordingly, in the i-th row and j-th column.The definitions of NPCR and UACI are(8)NPCR=∑i=1M∑j=1NM×N×100%,UACI=∑i=1M∑j=1NCii,j−C2i,jM×N×256×100%.The sizes of the picture areM and N, correspondingly.For our instance, the key “SecureMePlease!” has been used, and the chosen pixel is the position (1,2) of the image pixels. Its number is altered from (10100011)2 to (10100010)2. NPCR and UACI are therefore reported in Table2.Table 2
NPCR and UACI analyses.
Normal imagePassword imageNPCR0.0015%98.7778%UACI0.0000%30.9639%Table2 demonstrates how much greater our revised technique is programmatically than the original method in sensitivity.The responsiveness to the actual picture is quite low in the original method. The whole key picture in the256×256 sample provided has only been modified by roughly 0.0015 percent. The UACI is around 0 [11]. Experiments show that encrypted images are vulnerable to plaintext and known-plaintext attacks.Consequently, it is evident that our enhanced approach fixes the old system’s flaw of being blind to minute alterations in planar images. The encrypted picture’s pixels shift whenever a single pixel in the original picture changes (NPCR>98.77%), and the universal mean shift intensity increases (UACI>30.96%). The results demonstrate that the effectiveness is satisfactory.


## 4.3.2. Key Sensitivity Test

Crucial sensitivity is the pace at which a cryptographic picture’s pixel count changes even though only one piece of the password is changed. The usual image should first be encrypted with the testing password “SecureMePlease!” before the least-valid password is changed to “SecureMePlease.” and the identical image is encrypted. Consider the various password photos once more.The outcome is in regard to pixel gray levels, the encrypted image is completely different with a slight difference in the key (as shown in Figure7). Table 3 displays the outcomes of the encryption with different keys, with an average rate of change as high as 99.323%.Figure 7
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Encrypted image: key = “SecureMePlease!”(d)
Difference imageTable 3
Rate of change.
Original keyNew keyChange rateSecureMePlease!SecureMePlease.99.600%secureMePlease!99.161%SecuremePlease!99.245%SecureMePlease99.295%Also, if the image is encrypted with a key and decrypted with another, simply modified key, the decryption fails. Figure8 demonstrates how photos encrypted using the “SecureMePlease!” password cannot be properly decoded with the “SecureMePlease” password.Figure 8
Key sensitivity test.
(a)
Original image(b)
Encrypted image: key = “SecureMePlease!”(c)
Decrypted image: key = “SecureMePlease!”(d)
Decrypted image: key = “SecureMePlease!”


## 4.4. Other Security Analysis

### 4.4.1. Resist Plaintext Attack

We may observe a significant change at the crucial stream creation when evaluating the original method with the revised approach. The user’s passcode is the single factor that determines how the key stream is utilized in the original file, whether it is for an XOR operation with the actual picture or for postprocessing. It is separated from typical visuals. The key stream in our enhanced technique is based on the original picture’s properties as well as the user’s passcode. That is, although just use the same passcode, if various photos are encoded, the crucial stream of the XOR stage is unpredictable. This person assists with encrypted photographs defend against selected plaintext attacks and known plaintext attacks.Also, a cryptanalyst sending a dark image through into encryption method seems to have no impact on the operation because the key stream is varied when encrypting various images with the same cipher. The “chosen plain text assault” discussed above can be eliminated by our enhanced algorithm.


### 4.4.2. Diffusion and Chaos

Obfuscation and diffusion are two characteristics of secure cryptographic procedures that were first established by Claude Shannon in the field of cryptography. NPCR demonstrates that when just one pixel of the plaintext is altered, nearly every pixel in the cryptographic picture is altered, as illustrated in Section4.3.1 (NPCR>98.77 percent). The revised algorithm’s diffusion characteristics are excellent.Through the correlation analysis of the gray histogram and adjacent pixels, the proposed improved algorithm has good chaos.


### 4.4.3. Brute Force Attack

The suggested enhanced algorithm depends on the required space length and critical sensitivities for brute force attack evaluation.Essential space: the SHA-2 method and the FFT-DCT composite transform are irreparable processes, as was already stated; in addition, ARM will arrange the pixels, which is very secure for common commercial applicationsKey sensitivity: as shown in Figures7 and 8, even a small key change causes almost all pixels to change the corresponding cryptographic imageTherefore, our algorithm is highly resistant to brute force attacks.


## 4.4.1. Resist Plaintext Attack

We may observe a significant change at the crucial stream creation when evaluating the original method with the revised approach. The user’s passcode is the single factor that determines how the key stream is utilized in the original file, whether it is for an XOR operation with the actual picture or for postprocessing. It is separated from typical visuals. The key stream in our enhanced technique is based on the original picture’s properties as well as the user’s passcode. That is, although just use the same passcode, if various photos are encoded, the crucial stream of the XOR stage is unpredictable. This person assists with encrypted photographs defend against selected plaintext attacks and known plaintext attacks.Also, a cryptanalyst sending a dark image through into encryption method seems to have no impact on the operation because the key stream is varied when encrypting various images with the same cipher. The “chosen plain text assault” discussed above can be eliminated by our enhanced algorithm.


## 4.4.2. Diffusion and Chaos

Obfuscation and diffusion are two characteristics of secure cryptographic procedures that were first established by Claude Shannon in the field of cryptography. NPCR demonstrates that when just one pixel of the plaintext is altered, nearly every pixel in the cryptographic picture is altered, as illustrated in Section4.3.1 (NPCR>98.77 percent). The revised algorithm’s diffusion characteristics are excellent.Through the correlation analysis of the gray histogram and adjacent pixels, the proposed improved algorithm has good chaos.


## 4.4.3. Brute Force Attack

The suggested enhanced algorithm depends on the required space length and critical sensitivities for brute force attack evaluation.Essential space: the SHA-2 method and the FFT-DCT composite transform are irreparable processes, as was already stated; in addition, ARM will arrange the pixels, which is very secure for common commercial applicationsKey sensitivity: as shown in Figures7 and 8, even a small key change causes almost all pixels to change the corresponding cryptographic imageTherefore, our algorithm is highly resistant to brute force attacks.


## 4.5. Comparison of Similar Algorithms

The algorithm proposed in this paper has superiority by comparing and analyzing the algorithm of literature [12] and literature [13]. Reference [12] suggested a Feistel network-based picture encryption technique, which has high security and can be comparable to the algorithm in this paper, but there is a gap with this paper in terms of sensitivity. This paper also introduces in Section 4.3. The algorithm in this paper Fewer iteration rounds are required.In addition, although the literature [13] has been improved, the encryption speed of the algorithm in this paper is significantly higher than that of the literature [13]. Table 4 shows the image encryption algorithms proposed in this paper, literature [12] and literature [13]. The time required to encrypt the same image, it can be seen that the encryption speed of this paper is the fastest that is because the literature [12] uses a large number of iterations, resulting in a slow operation, while the literature [13] is because there are too many rounds. This results in increased computation time, which in turn slows down encryption.Table 4
Encryption time of three encryption algorithms.
Encryption algorithmImage sizeEncryption timeLiterature [12]90∗1802.13Literature [13]128∗1281.24The algorithm in this paper128∗1280.15


## 5. Conclusion

In this research, we suggested a hash-based fast picture encryption algorithm for Internet of Things (IoT) applications, where the image is split into equivalent left and right portions, and the data from one half is used to encrypt the other part in turn. Theoretical study and computer simulation demonstrate the robustness of our suggested approach against chosen plaintext assaults as well as chosen plaintext attacks.



---

*Source: 3173995-2022-08-10.xml*