A Hash-Based Fast Image Encryption Algorithm

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 uni ﬁ ed average changing intensity ( UACI > 30 : 96 percent) and only one pixel di ﬀ erence 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 ﬁ x 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.


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].

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].

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 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 image B. 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.

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 variables a, b, and k. To create the three variables that will substitute the efficient algorithm, we utilize Ki = HðHð KeyÞ. 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.
x n+1 (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

Encryption
(1) Identical to steps one and two of the initial step (2) Generate a new key stream K 0 with image features. First, the original image is divided into two equal parts L 0 and R 0 in the vertical direction, and the two parts are encrypted, respectively, and the formula is as follows. First, encrypt the information of R 0 using L 0 to R 1 ; the right part has been encrypted. Then, L 0 is encrypted to L 1 using R1's information (3) Finally, to acquire the cipher picture, combine the 2 encrypted components L 1 and R 1 L 0 and R 0 throughout the example above stand for the left and right sides of something like the pure picture, while L 1 and R 1 stand for the left and right sides of the cipher image, g L 0 and g R 1 represent the average gray value of L 0 and R 1 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 images Figure 3 depicts the encryption process algorithm. Figure 4 depicts the key stream creation algorithm.

Decryption.
To obtain the XOR key stream, firstly invert the ACM.
Encrypt the XOR key stream to produce a plain picture next. L 1 to L 0 first were encrypted using R 1 's data. Next, as stated in the following expression, utilize the data from L 0 to decode R 1 to R 0 . L 0 and R 0 are the left and right halves of the plain image, whereas L 1 and R 1 are the left and right halves of the encrypted image. Figure 1: Mapping process.

Wireless Communications and Mobile Computing
Finally, the two decrypted parts L 0 and R 0 are connected together to obtain a decrypted image.

Performance Analysis
In this section, a 256 × 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.
The graph of the password picture is quite homogeneous and distinct from the actual picture, as shown in the figure.
where the gray scale values of the adjacent image pixels are represented by x and y. Figure 6 depicts, correspondingly, the horizontal, vertical, and diagonal correlations between the two images. Table 1 displays the findings of the regression analysis of adjacent pixels.

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.

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, C 1 and C 2 , which normal control pictures vary by just one pixel. The gray scale values of the encrypted images C 1 and C 2 are designated as C 1 ði, jÞ and C 2 ði, jÞ, accordingly, in the i-th row and j-th column.
The sizes of the picture are M 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 Table 2. Table 2 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 the 256 × 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.

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 Figure 7). Table 3 displays the outcomes of the encryption with different keys, with an average rate of change as high as 99.323%.
Also, if the image is encrypted with a key and decrypted with another, simply modified key, the decryption fails. Figure 8 demonstrates how photos encrypted using the "SecureMePlease!" password cannot be properly decoded with the "SecureMePlease" password.

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.  Through the correlation analysis of the gray histogram and adjacent pixels, the proposed improved algorithm has good chaos.

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 applications Key sensitivity: as shown in Figures 7 and 8, even a small key change causes almost all pixels to change the corresponding cryptographic image Therefore, 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.

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.

Data Availability
All the data used to support the findings of this study are available in the article.

Conflicts of Interest
No contradictions exist, according to the researchers, with the publication of this research.