Security enhancement and analysis of images using a novel Sudoku-based encryption algorithm

ABSTRACT This paper presents a novel approach for encrypting images using a Sudoku as its encryption key. This algorithm uses both symmetric and asymmetric key cryptography. It works with any type of data, Sudoku size, and keyspace. The image undergoes the process of modified thresholding, using a pseudo-random number generated from a Sudoku as the threshold. This image is then padded with zeros or the average pixel values to ensure the dimensions are multiples of the Sudoku's size and the image rows are shuffled randomly. For each iteration, the image rows are shuffled, followed by the columns, and finally, the image is rotated clockwise by 90 degrees. The resultant image is highly encrypted and resilient to brute-forcing methods. The algorithm requires roughly 25 milliseconds per iteration for a colored square image of dimensions and has an NPCR value of 99.60% and a UACI value of 35.65%. The gargantuan keyspace offered by the Sudoku keys ensures obedience of Kirchoff's principle and Shannon's maxim.


Introduction
In 2022, more than 3.5 quintillion bytes of data were generated globally every day (Earthweb, 2023). This amount is growing exponentially as the use of smart devices increases. Almost every little piece of data (Mune & Bhura, 2020) is being stored somewhere forever in this internet era. In such a scenario, data encryption assumes prime importance. It is needed to maintain privacy, as there always are dishonourable elements of society trying to gain disallowed access to someone's private data (Mhatre et al., 2022). Often, the goal of such attackers is to leak this private data to cause colossal losses to individuals and organizations. In other cases, it is to use this private data for blackmail or ransom or is sometimes done just to cause trouble for the victim (K. Mehta, Dhingra, et al., 2022;Sawant et al., 2022).
One way to avoid these issues is data encryption. The sender of this data should encrypt it so that it is stored safely and can be decrypted by the intended receiver when required. The main goal of an encryption algorithm should be that encryption and decryption processes be extremely fast and yet withstand any attacks that can crack them. Various techniques of encipherment, such as the RSA Encryption Algorithm, Advanced Encryption Standard (AES) algorithm, Hill Cipher (Rajvir et al., 2020), Shift Cipher, Affine Cipher, Vernam Cipher, etc. have been developed in the past. There, however, is a need for the creation of new encryption techniques as aggressors all over the world ceaselessly endeavour to crack these algorithms. No algorithm remains foolproof over time as ingenuity lies not only with the creator of an encryption algorithm but also with the attacker, who is guaranteed to find a solution sooner or later. Hence, an algorithm creator should always bear in mind that the attacker might be aware of the system, that is, the working of the algorithm, and hence the algorithm's security relies on the keys, according to Kirchoff's principle and Shannon's maxim (Jajodia & van Tilborg, 2011).
A classic Sudoku is a Japanese puzzle (Felgenhauer & Jarvis, 2006) which contains nine rows of nine columns each where each row contains the first nine positive integers shuffled in a manner in which the numbers appear only once in the individual rows or the 3 × 3 grids formed by these rows.
It has been observed that a structured, mathematical entity in which a pattern exists, such as a Sudoku, is an outstanding producer of complex, hard-to-decipher, and sizeable keyspaces. Taking into account the requisites of a high-quality encryption algorithm described above and using the unique capability of a Sudoku to provide a massive keyspace as described in Section 5.1, which allows obedience of Kirchoff's principle and Shannon's maxim, this paper deferentially attempts to contribute to the world of cryptography, a new symmetric-key block cipher encryption technique based on the patterns found in a traditional Sudoku puzzle. The algorithm is later extended to Sudokus of other sizes. This algorithm encrypts an image in several iterations at a blazing pace using a Sudoku as the key for each iteration of this process which scrambles the data in 'blocks'. This paper has been written for an image file  as the data to be encrypted. The same principles can, however, be applied to any form of data that can be divided into smaller blocks and processed individually. Several randomly generated Sudokus are used as the keys for each round of encryption. The encryption algorithm works on blocks of sudoku-sized data units at a time. To ensure a higher level of encryption, the technique uses multiple rounds of encryption done using a transposition cipher so that the actual data cannot be easily retrieved from the encrypted data without using the keys. This algorithm is highly flexible, works with custom keyspaces and different Sudoku sizes, and takes the keys as input.

Related works
In the 'Plain Text Encryption Using Sudoku Cipher' by Dey et al. (2019), the authors use the Sudoku Cipher for encrypting plain text data based on a fixed 9 × 9 grid of a Sudoku. The added benefit of this is during transmission, in case any modifications are done to the encrypted message, they can easily be detected, as they may violate the uniqueness limitations in each row, column, or mini-grid of the Sudoku puzzle.
The 'Speech signal compression and encryption based on Sudoku, fuzzy C-means, and threefish cipher' by Abduljaleel and Khaleel (2021) makes use of the Sudoku in an intermediate step as a scrambling technique along with the Fuzzy C algorithm to achieve encryption on audio files before passing the data to threefish algorithm for further encryption and compression.
In 'A simplified data encryption standard algorithm' by Schaefer (1996), a new and simplified version of the data encryption algorithm is presented where all the parameters are reduced as much as possible, which makes the inner workings of the algorithm accessible to undergraduates with the intention that the knowledge of the working can be extrapolated to the non-simplified version of the data encryption algorithm.
In 'An empirical study to compare the performance of some symmetric and asymmetric ciphers' by Kofahi (2013), Elliptic Curve Cryptosystem (ECC) asymmetric encryption algorithm is compared with symmetric block cipher algorithms, namely Triple-Data Encryption Standard (T-DES) (Coppersmith et al., 1996), Advanced Encryption Standard (AES), and Blowfish. The evaluation is based on key generation, encryption, and decryption to determine the key size, security strength, and speed. The result of this evaluation was that ECC proved to be better than others in terms of security strength and is also scalable for future requirements.
'A new image encryption algorithm for grey and color medical images' by Kamal et al. (2021) introduces a new image splitting technique based on image blocks. These image blocks are then encrypted by scrambling them in a zigzag pattern with rotation and random permutations. A chaotic logistic map is then used to generate a key to decrypt the medical image. This algorithm proved to be more efficient than any other medical image encryption algorithm (Choi et al., 2020;Jeong et al., 2018).
In 'A Combination of Block-Based Chaos with Dynamic Iteration Pattern and Stream Cipher for Color Image Encryption' by Budiman and Setiadi (2020), a new encryption method is proposed which is based on using a combination of chaotic methods (Y. Li et al., 2021), streams, and hash functions (Applebaum et al., 2017). The hash algorithm used is SHA-1 and the image is divided into blocks which are encrypted by a dynamic key pattern based on chaotic keys.
In 'A New Algorithm For Digital Image Encryption Based On Chaos Theory' by Pourasad et al. (2021), the feasibility of Chaotic methods-based digital image encryption is checked as this technique makes use of random chaos sequences for encryption of the image, and it is a quick and highly-secured method but has limited accuracy. The analysis was done on various performance metrics such as the Unified Average Changing Intensity (UACI), Correlation coefficient, Peak Signal to Noise Ratio (PSNR), and Number of Pixels Change Rate (NPCR). The result of this analysis as shown by the simulation, is that this technique is effective and can be used to encrypt images.
In 'Image Encryption using the Sudoku Matrix' by Y. Wu et al. (2010), the authors have proposed a lossless method of encrypting an image using a Sudoku as a reference matrix to create a chaotic sequence using a logistic map to change pixel intensities as the first step and then using the reference matrix again to scramble the image by changing the position of the pixels. Only one Sudoku puzzle is used for the entire algorithm. The authors have manipulated the images such that high diffusion is achieved making the encrypted image completely unrecognizable.
In 'Image Encryption with Variable Length Key' by Guanghui et al. (2016), the authors have proposed a new encryption scheme for images with a variable length running key created from a modified tent map (C. Li et al., 2017). It can create a uniformly distributed sequence of pseudo-random numbers. This encryption technique is resilient to the known/chosen plaintext attack.
In 'A Combined Sudoku and Synthetic Colour Image Techniques for Cryptographic Key Generation' by Manikandan et al. (2021) the authors have proposed an algorithm for key generation which involves generating 8 × 8 Sudoku values generated from random sessions wherein after solving these Sudoku puzzles using the recursive as well as backtracking techniques Sudoku matrices are obtained from which bits of pixels of a synthetic color image are extracted to form a key.
In 'An Efficient Three Layer Image Security Scheme using 3D Arnold Cat Map and Sudoku Matrix' by Meenakshi and Manivannan (2015), the authors have proposed three-layer encryption for greyscale images. After exposing the greyscale image to the 3D ACM cipher layer, the image is first shuffled according to the Sudoku matrix permutation and then ex-ored with this matrix.
In 'Image Encryption Algorithm Based on a New Five Dimensional Hyperchaotic System and Sudoku Matrix' by Mehdi and Kadhim (2019) the authors have attempted to create a chaotic sequence using a Sudoku matrix for key generation. The chaotic sequence is used to shuffle the image, then carry out an ex-or operation between the shuffled image and the Sudoku matrix, shuffle the image again, and then carry out another ex-or operation between this image and the chaotic key.
In 'Image encryption based on permutation-substitution using chaotic map and Latin Square Image Cipher' by Panduranga and Naveen Kumar (2014) the authors have demonstrated an encryption scheme for images based on permutations using chaotic maps and Latin square image cipher. The demonstrated technique comprises permutation and substitution steps. In the permutation step, the permutation of the target image is done according to a chaotic sequence generated using a chaotic map. In the substitution step, a 256 bits secret key is used to generates a Latin Square Image Cipher (LSIC) which is used as the key image to perform an XOR operation between the permuted image and the key image. This method can be used for any image of any desired dimensions.
In 'A Novel Color Image Encryption Algorithm Based on Hyper-chaotic System and Permutation-Diffusion Architecture' by Wang et al. (2012), the authors have proposed an encryption technique for colored images based on hyper-chaotic systems and the permutation-diffusion architecture. This algorithm makes use of a permutation block generated by mixing the red, green and blue components of a pixel. Using this algorithm, high diffusion is achieved and two entirely different encrypted images are obtained despite change of the last pixel only. Tests reveal that this algorithm is resistant to statistical and differential attacks.
In 'A novel image encryption algorithm based on chaotic shuffling method' by Wang et al. (2017), an encryption technique to encrypt color images based on a chaotic shuffling-diffusion method has been proposed. The algorithm involves the generation of a chaotic sequence by a logistic map (Kocarev & Jakimoski, 2001), which is used to label the row coordinates of pixels of the shuffled image. Next, another logistic map is used for labeling the column coordinates of pixels of the shuffled image. Then, using the proposed pixel exchange model, the image is shuffled to change the position of pixels. After this, a matrix that is of the same size as the original image is generated by a third logistic map to enlarge the key space employing the MOD and the XOR operations. This algorithm is resistant to statistical, differential, plaintext, and the chosen-plaintext attack.
S-boxes short for substitution boxes are non-linear components used to achieve the confusion in block ciphers. In 'S-box design method based on improved one-dimensional discrete chaotic map' by Lambié (2018), the author has proposed a new method for generating s-boxes using one-dimensional discrete chaotic maps, recording a forty-three percentage increase in creation speed and a gain of thirty-two percentage in space utilization. This approach is useful in fields where complete digitization is required and in lightweight devices with compact memories. Dang et al. (2021) describes a way of sharing data in a secure and encrypted manner on a peer-to-peer network (P2P) by making use of blockchain technology. Data is encrypted by making use of an attribute-based encryption algorithm to share keys amongst a group of authorized users, while the blockchain network ensures proper distribution of the keys. By having multiple copies of the data in the blockchain nodes, the proposed system is immune to the possibility of data unavailability due to the crashing of peer nodes. The authors have compared different types of attribute-based encryption algorithm and have used ciphertext-policy attribute-based encryption (CP-ABE) in their implementation. Although this system is vulnerable to quantum computing attacks, the authors predict quantum computers to be years away and expect a quantum-proof implementation by that time.

Methodology
This section describes the encryption pattern, encryption algorithms and the working of our Sudoku-based encryption algorithm.

Encryption pattern
The algorithm follows a symmetric-key block as well as a transposition encipherment pattern which makes use of n + 4 keys, where n is the number of rounds that the algorithm iterates over: . The Sudoku size: The size of the Sudoku can be modified to enhance security. For example --the algorithm can make use of a 16 × 16 Sudoku puzzle as the key instead of the standard 9 × 9 . The first key: an integral number --the height of the original image to be encrypted. . The second key: an integral number --the width of the original image to be encrypted. . The third key: an integral number --the number of rounds of encryption that the Sudoku undergoes, which can be as low as one or as high as a thousand, depending on the encrypter's satisfaction. . 'n' more keys follow, depending on the value of n in the first key. These keys are the randomly generated Sudokus, which encrypt the data in blocks of the Sudoku size. A standard Sudoku contains 9 blocks of 9 digits each, ranging from 1 through 9. . The (n + 4)th key: a seed value generated from a list of numbers ranging from 0 to the height of the padded image (first value inclusive, second value exclusive).
Since the data is processed in blocks of Sudoku size, and each element in the block is scrambled to form permutations generated to the tune of each sub-block of the Sudoku keys, this technique can be classified as a block transposition cipher. More accurately, the algorithm can also be called a multi-level block transposition technique, as for a standard 9 × 9 Sudoku, the data is being permuted in 9 sub-blocks of 9 such rows corresponding to each row in the Sudoku. This shuffles the data in blocks of 9, per row of the key, but in blocks of 81 per round of encryption.
To make the algorithm more secure, the sender can choose to encrypt the keys themselves by using any asymmetric key encryption technique (Srivastava et al., 2022). The sender encrypts each of the n + 4 keys (n is the number of rounds of encryption in the algorithm) and sends the keys encrypted with the asymmetric key encipherment technique along with the data encrypted using the original n + 4 keys (Mune & Bhura, 2022). The receiver can then decrypt these keys using their private key.
As an optional feature, the input custom keyspace can also be stored in 'keys.txt'. These keys are variable in length and characters governed by the desired input from the user. This can further enhance the security as the custom keyspace complicates the decryption of the keyspace first, followed by further encryption. As an example, a user might want the number '3' to be represented as number '5', the number '9' to be represented as number '2' and so on. This keyspace can be completely devoid of logic as it is governed by user choice, and may be difficult to crack.

Algorithms
The pseudo-code of the encryption and decryption algorithms is shown in this section. The encryption process has four parts. First, the algorithm generates all keys necessary for the encryption process followed by the generation of a pseudo-random number. This random number is used for the process of 'thresholding' in the image. The third step describes the creation of padding around the image followed by the actual encryption algorithm.
The decryption process used to reverse the effects of encryption is described in the next three steps. First, the decryption algorithm inverts the effects of the row and column shuffling followed by the step to remove the padding around the image. The final step in decryption is the restoration of the original image by the removal of the effects of thresholding.
Algorithm 1 Read Image, Store Keys 1: read the image 2: store the height and width of the image as the first two keys in 'keys.txt' 3: SudokuSize = input size of the sudoku 4: if user wants custom keyspace then 5: keyspace = input the custom keyspace. 6: convert the custom keyspace into the equivalent interger keyspace. 7: end if 8: n = input number of encryption rounds. 9: store n in 'keys.txt' 10: input n Sudoku keys or generate randomly using seed values from keys.txt. 11: store the n keys in 'keys.txt'. Algorithm 3 Image Padding 1. if height<SudokuSize then 2. add padding SudokuSize -height 3. else if width<SudokuSize then 4. add padding SudokuSize -width 5. else if height % SudokuSize ! = 0 then 6. add padding (height//SudokuSize+1)*SudokuSize -height 7. else if width % SudokuSize ! = 0 then 8. add padding (width//SudokuSize + 1)*SudokuSize -width 9. end if 10. randomly shuffle each array of image according to seed value 11. store the padded & shuffled image. 12. store the height of padded image as seed value in 'keys.txt' as the final key Algorithm 4 Sudoku Based Encryption 1. shuffle the rows of paddedImage with the last key of 'keys.txt' the seed value. 2. for (i = 1; i , n + 1; i + +) do 3. read Sudokus from the key.txt file. 4. shuffle image pixels in the row in blocks of SudokuSize according to Sudoku K n . 5. shuffle the image rows in batches of SudokuSize according to Sudoku K n . 6. rotate image clockwise by 90 degrees. 7. end for 8. store the encrypted image.
Algorithm 5 Sudoku Based Decryption of Encrypted Image 1. im = read image to be decrypted. 2. reverse shuffle rows of paddedImage with the last key of 'keys.txt' as the seed value.
3. for (i = 1; i , n + 1; i + +) do 4. rotate image anti-clockwise by 90 degrees. 5. read Sudokus from the key.txt file in reverse order. 6. reverse shuffle image pixels in each row in blocks of sudokuSize according to Sudoku K n . 7. reverse shuffle image rows in batches of sudokuSize according to Sudoku K n . 8. end for 9. reverse shuffle image rows using the last key of 'keys.txt'. 10. obtain padded, decrypted image with thresholding.
Algorithm 6 Remove Image Padding 1. im = decrypted, padded image 2. h im , w im = height & width of im 3. read height and width of image from key space as h key & w key 4. remove (h im − h key )/2 padding from bottom and top. 5. remove (w im − w key )/2 padding from left and right. 6. store the image obtained after removal of padding.

Implementation
This section describes the encryption and decryption techniques of the algorithm in detail.

Encryption
The encryption technique has been described in this section. The first step of the algorithm involves reading the image in a particular format. The picture is read as a two-dimensional array, with the first dimension being the height of the image and the second dimension being the width. Every element of the inner array is either a pixel value if the image is gray-scale or a tuple in the RGB (Red-Blue-Green) format if the image is a color image. This particular format is critical for the shuffling process in the iterative phase of the algorithm. The height and width of the image are stored as the first two keys of the algorithm in 'keys.txt' which contains all the keys.
The second step requires user input for the Sudoku size the user wishes to use in the encryption process. A larger Sudoku size would ensure a higher level of encryption but also require more time. Then if the user wishes to use a custom keyspace, they can enter that stored in the keys.txt file and convert it into the equivalent integer keyspace for the encryption process.
The third step calls for user input of the fourth key, which is the number of rounds of encryption. The n subsequent keys, the Sudokus, are generated or manually entered by the user. The algorithm will only accept as many Sudokus as the rounds of encryption of the user's first inputs. The user can always return and re-encrypt the image if he feels that the encryption obtained is insufficient. The first key is then saved to a text file where the subsequent n + 1 keys shall be stored.
Step four involves the generation of random Sudokus by the machine. Users also have the option to enter their Sudoku puzzles as keys manually. These subsequently generated or manually entered Sudoku puzzles are saved to a text file for storage or transmission, with each key being written on a new line.
The fifth step of the algorithm is the thresholding process, modified for this algorithm as follows. A pseudo-random number, considered a threshold for this algorithm, is obtained by adding the elements along the diagonal from the top left of the image to the bottom right. If, on adding this number to the pixel in the case of gray-scale images or to its red, green, or blue value in the case of color images, the number obtained is smaller than 255, which is the highest permissible value of a pixel, the pixel value is set to this number; otherwise, the pixel value is set to this value subtracted from 255. This provides an image with a color scheme that contrasts the original image within the limits of the random number generated. The word "thresholding" has been used, keeping in mind that the pixel value is modified based on the pseudo-random number.
Since the dimensions of the input image are variable, the sixth step of the algorithm has two parts, the first is adding padding around the entire image to make the height and width of the image a multiple of the Sudoku size. As an example, if the Sudoku to be used for the image is of size 9 × 9, the padding shall ensure that the dimensions of the image are a multiple of 81 since a Sudoku of this size gives a square with 81 values transposed on the image as it horizontally reflects on it. For a Sudoku of size 16 × 16, the padding would make the image's dimensions a multiple of 256. The padding can be calculated after reading the image, converting it into arrays of pixels with an equal number of padding pixels at the top and bottom as well as on the right and the left. The padding on the sides may or may not be equal to the padding on the bottom and top, depending on the figure's dimensions. The padding added to the image is usually the most common pixel value found in that image. There are several other methods of generating the padding, as well. One can create the pixel padding using the red, blue, and green values obtained by averaging all the values found in the image. The height of this padded image is stored in the file 'keys.txt' as the final key of the process.
The second part of sixth seven is shuffling the image according to the final key. This scrambling (Y. Li et al., 2016) has been done to introduce randomness into the algorithm. Once the image has been scrambled and padded, it is ready to enter the actual encryption rounds, which involve using the n Sudoku keys. It can be noted that the padded image is encrypted; hence, the encrypted image contains extra padding when the sender communicates it to the receiver. An attempt at removing the padding shall result in data loss as the padded borders are also involved in the encryption process.
The image next enters the iterative phase. The user has decided the number of iterations stored in the first key. If the user is unsatisfied with the result of the encryption, they can always try the algorithm with a higher number of iterations. First, the Sudoku puzzles are read from the key file. The image, having entered this iterative phase, undergoes the following transformations. Every array in the picture is divided into smaller arrays of length equal to the Sudoku length. Next, the smaller arrays are shuffled according to the combination in which each array in the Sudoku is obtained. This shuffling process is used in the iterative phase, part two of the fourth step, and the final stage of the algorithm takes inspiration from the Simplified Data Encryption Standard (S-DES) algorithm, where the given binary string is permuted according to the sequences provided. Note that the standard Sudoku is an array containing nine arrays containing nine elements.
Next, the rows are shuffled in batches of Sudoku size according to the Sudoku of the appropriate round. This ensures that the individual pixels and the entire rows of pixels are reorganized. This improves the diffusion property of the algorithm, as shuffling only the rows or the pixels in the rows is insufficient. For every iteration, the final sub-step involves rotating the image 90 degrees clockwise.
After the iterative phase is complete, the final step involves another random shuffle of the entire image in the order defined in the second key. This gives us an encrypted image ready for transmission from the sender to the receiver. Figure 1 describes the entire encryption process as a flow chart.

Decryption
The decryption technique has been described in this section. This process reverses the effects of encryption obtained from the technique described in the previous section. It involves three steps: the reversal of the iterative phase, the removal of padding, and the reversal of the effect of the modified thresholding. The first step is the inversion of the random shuffling of the columns based on the seed value stored in the 'keys.txt' file. The next step is the iterative phase wherein firstly, the image is rotated counterclockwise by 90 • followed by the inversion of the row and column shufflings of the image based on the Sudoku keys in the reverse order of their storage. The row decryption is obtained by dividing every single image array into rows of the size of the length of the Sudoku puzzle and then performing the reversal operation on each smaller array. The last key of 'keys.txt' is again used to remove the effect of randomization of the arrays that constitute the columns of the image. This proffers a decrypted image that still possesses the padding and the thresholding.
The padding is removed based on the height and width stored in the keys. The padding length equals the actual height and width of the image subtracted from the total height and width of the padded image and is subtracted evenly from the top, right, bottom and left of the image.
The thresholding of the image is reversed by subtracting the pseudo-random number from each pixel value in the case of gray-scale images or the red, green, and blue values that constitute a pixel in color images and obtaining the original pixel value greater than or equal to 0, or adding 255 to the obtained pixel value if a negative integer is obtained. Figure 2 shows the entire decryption process as a flow chart.

Results and discussions
For the tests, the standard image of 'Lena' of size 512 × 512 pixels originally in the '.tif' format was used. The image transformations after modified thresholding and 50, 75, and 100 iterations were observed. The rotation of the image and the shuffling of the pixels using the keys make the images chaotic and unrecognizable. The essence of the algorithm lies in the strength of key generation and not in the actual shuffling of the pixels where very little diffusion occurs. This is because the algorithm relies more on the fact that the key space is beyond the computation power of any normal computer or even the more advanced supercomputers for which tougher variations of this algorithm --which were described previouslycan be used. Additional tests are on different types of images. The second image that is encrypted is a black-and-white image of a forest. The third image is of multi-colored quadrants of a square to show how diffusion is taking place in the algorithm. The fourth image is a symmetric image of the Eiffel tower. The fifth image is the image of an Orca, and the final image is a mirror image of towers. A histogram of the image before and after encryption is also displayed to show the confusion and diffusion of the image due to encryption.
The images were tested using 9 × 9 Sudokus and 16 × 16 Sudokus to show the changes in the output image and the time changes reflected in the encryption process. The results are visualized as follows: 4.1. Results obtained using 9 × 9 Sudoku

Analysis of results
This section analyses the algorithm using different metrics. Firstly, the key space analysis gives an insight into the various combinations of the keys that can be created with the suggested technique to reduce the key size that is stored or transmitted. Secondly, the security analysis is a description of the vulnerability of the algorithm to various types of attacks. Thirdly, the time complexity analysis is a demonstration of the real world running time of the algorithm. Fourthly, the average pixel intensity value analysis shows the changes in the average RGB pixel values of the images before and after the encryption process is done. Finally, the key sensitivity analysis describes the diffusion pattern of the algorithm.

Key space analysis
The only restriction on the user input value n is that is needs to be lesser than the maximum number of possible solvable Sudoku grids combinations which are 6 sextillion, 670 quintillion, 903 quadrillion, 752 trillion, 21 billion, 72 million, 936 thousand, 960. n , 6, 670, 903, 752, 021, 072, 936, 960 For the transposition combination after the Sudoku-based scrambling encryption, we randomly shuffle an array of the same size and store the value. The number of possible randomly shuffling combinations is equal to the height of the image that is to be encrypted. Combining this with the Sudoku possibilities, the total number of possible key     combinations increases drastically and is in the power of a septillion. 6,670,903,752,021,072,936,960 If still a larger key space is needed then a Sudoku of larger grid size can be considered as it will have more possible combinations. For instance, a 10 × 10 Sudoku can be has 1,903,816,047,972,624,930,994,913,280,000 possible combinations. With such a large key space, brute-forcing the algorithm will take up a lot of time even with a fast computer, which is the requirement of a good encryption technique (Phan, 2004). As of July 2022, the world's fastest supercomputer is the Hewlett Packard Enterprise Frontier with a processing speed of 1.102 exaflops per second. For an image of 400 × 400 pixels with n = 100 encryption rounds, the total possible combinations of the keys would be 4.2 × 10 892 combinations. Dividing the number of possible combinations by the processing speed, we get 3.88 × (10 874 ) seconds which is approximately equal to 10 867 years.
So, even with the world's fastest supercomputer, it is impossible to try all possible combinations rendering this algorithm immune to brute-force attacks.

Reducing key size
Instead of sending the entire Sudokus as the key to the encryption algorithm, one way could be using python libraries like py-sudoku that can generate custom-sized Sudokus from a seed value. This seed value can either be a user input or randomly generated by the computer. This seed value can be easily cracked using public key cryptography. However, using symmetric key cryptography by deciding an arbitrary seed value, we can avoid any compromise on security.
As a result, key size per Sudoku can be drastically reduced from a 9 × 9 array in the case of the Standard Sudoku to a single integer number. This does not compromise the algorithm's security as even though a Sudoku can be seeded from the library, there are still 6,670,903,752,021,072,936,960 possibilities for a single 9 × 9 Sudoku key.

Security analysis
The security of an algorithm is directly proportional to its key size. In this scenario, the total key size would n * log 2(10) + (1/2 * ( log 2(10)) * h * (h + 1)) + 324 * n bits. where n is the number of encryption rounds and h is the height of the image that is to be encrypted. With such a large key size, it is almost impossible to guess the key and as proven in the key space analysis, the brute force technique is also not the easiest way of cracking the encrypted data.
One vulnerable point can be when the key itself needs to somehow be transmitted to the receiver. For this, we can make use of asymmetric key encryption algorithms such as RSA or Diffie Hellman which will ensure the authenticity of the key for both sender and receiver.
Another method of making the key more secure would be to define an arbitrary key space which would involve the use of different symbols substituting the numbers in the Sudoku keys. For example, for a sample Sudoku (Figure 99)  The security of this algorithm can be further enhanced when unsolved Sudoku puzzles are stored and transmitted as keys. This gives an added advantage to the security as solving a Sudoku is computationally NP-complete. Further, a Sudoku ceases to be unique if there are less than 17 clues in it, and thus transmitting several such Sudokus would make it impossible to crack them if the creator keeps track of the clues which are not stored in the key itself. A simple solution would be to encrypt the number in these clues as well as their position inside of the Sudoku matrix using a different encryption technique.

Average pixel intensities analysis
The pixel values of any image are usually described in the form of a histogram. The more different the histogram values of the encrypted image are from the original image, the better the encryption, as it reduces the possibilities of statistical attacks on the image.
In Table 5, a comparison of the average pixel intensities is shown between the original images and the encrypted images using 9 × 9 Sudokus and 16x16 Sudokus. It is seen that there is a significant change in the average pixel values after the encryption showing the confusion element of the encryption.

Information entropy analysis
Entropy, in general, refers to randomness. For cryptographic use cases, the higher the entropy values, the higher the security is considered, as it increases the difficulty in  finding the randomly generated value since the formula reversal method is no longer available. Shannon entropy is a common way of finding out the information available in every pixel. It works by quantifying the absolute amount of storage and transmission needed to capture information stored in a variable based on the frequency of data values.
The above equation is the Shannon Entropy equation where 'H(X)' is the information entropy for the image, 'Pi' is the probability of the variable 'Xi' and 'N' stands for the total number of variable values available which is 256 in the case of greyscale images. According to Hamza and Titouna (2016), the highest possible Shannon Entropy value is 8 and any value even close to 8 is considered to have good entropy. In Table 6, Shannon Entropies of the original and encrypted images are compared. We can confidently say that the encryption process increases the Shannon entropy of the images and brings it much closer to the highest possible value i.e. 8.
In Table 7, the Information Entropy of the proposed algorithm is compared with other algorithms using Lena as the base value. We can thus conclude that our proposed algorithm has a better information entropy than most algorithms but still falls behind some (Roy et al., 2021) by a slight margin.

Key sensitivity analysis
The encryption algorithm is based on multiple randomly generated Sudokus as the keys. Changing just one Sudoku does not drastically affect the encrypted image, as the diffusion ability of this algorithm is low because only 81-pixel tuples are shuffled per Sudoku. The algorithm is also not acutely affected in a single iteration for the same reasons. If, however, all the Sudoku keys are different, then the final encrypted image would be entirely different. Iterations also make the image more chaotic, proving their importance in this algorithm.

Analysis of differential attacks effects
NPCR (Number of Pixels Changed Rate) and UACI (Unified Average Changing Intensity) are metrics used in differential attacks on encryption systems to evaluate the strength of encryption algorithms. These attacks exploit the fact that small changes in the plain text will result in small changes in the cipher text, known as differential characteristics. NPCR measures the proportion of pixels in an image that is changed after encryption, while UACI measures the average intensity of the changes.
A higher NPCR or UACI value indicates that a larger number or proportion of pixels change after encryption, making the encryption more secure against differential attacks. Conversely, a lower NPCR or UACI value indicates that the encryption is more vulnerable to differential attacks.
Suppose C 1 represents the plain-text image and C 2 represents the cipher-text image, and the pixel values at grid (i, j) are represented by C 1 (i, j) and C 2 (i, j) respectively. D(i,j) is a bipolar array as described in Equation (2).
The range of NCPR values and UACI values is from 0% to 100%.   Wu et al. (2018) 7.9895 Baptista's algorithm (Zhang & Liu, 2011) 7.9260 Wong's algorithm (Zhang & Liu, 2011) 7.9690 RC5 (Hanchinamani & Kulakarni, 2014) 7.9812 RC6 (Hanchinamani & Kulakarni, 2014) 7.9829 The MSK (Roy et al., 2021) 7.9983 conclude that using a bigger Sudoku increases the NPCR value in all cases and the UACI value in majority of the cases making the encrypted images more resilient to differential attacks. Table 9 compares the NCPR and UACI values of the proposed algorithm and other available encryption algorithms using Lena as the standard image. From this table, we can conclude the proposed algorithm is very close to current industry standards and even surpasses some of them in some cases.

Applications
The complexity of this algorithm makes it suitable for image encryption and transmission in applications with abundant storage and processing power (Balani et al., 2022;Pampattiwar & Chavan, 2021). This can be done to encrypt movies and videos, which are a sequence of images, to reduce piracy and theft of data.
Journalists can make use of this algorithm to securely transfer images so that they do not get leaked before being published. Using fixed locations of Sudoku for example The Times Of India daily Sudoku can even remove the process of sending the key and therefore eliminate a possible loose end in the overall security of the data.
Another application of this algorithm would be in text cryptography, where a user possesses texts in different languages using various symbols that can be defined in custom keyspaces, shuffled using the Sudoku keys, and transmitted. Including timestamps with the image would assist in reinforcing image integrity.

Conclusion and future scope
This document demonstrated a new image encryption algorithm based on the Japanese puzzle Sudoku. This encipherment technique followed the block cipher approach and  Norouzi et al. (2014) 99.65 33.55 Arpaci et al. (2020) 99.62 33.44 D. Mehta, Jha, et al. (2022) 99.61 33.58 Seyedzadeh and Mirzakuchaki (2012) 99.67 33.49 involved shuffling data and its values using multiple Sudokus as keys on several different images. Results exemplified a resistance to various attacks, especially the brute-force attack. They proved that as the image underwent more iterations, the obscurity of the original image increased, exhibiting greater diffusion, and the pixel value changes based on sudoku values introduced confusion in the final encrypted image. A wide range of analyses was done on the algorithm to gauge its effectiveness, such as key space analysis, security analysis, time complexity analysis, average pixel intensities analysis, information entropy analysis, key sensitivity analysis, histogram analysis, and differential attack effects analysis. From these analysis, we can conclude that this algorithm is quite secure and performs better than the majority of the other encryption algorithms it is compared to. In some cases, where other algorithms perform better, they do by a very slight margin.
Although this paper covered image encryption, but the algorithm can encrypt practically any form of data, including but not limited to multimedia data such as audio, video, and plain text, as well as various discrete signals available in multiple dimensions. The only requirement is that the data be capable of fragmentation which is essential for the modification, transposition and shuffling of the data.
The future scope would involve implementing this algorithm on not only different images but also images of different file formats and observing the variations in the time and space complexities of the outputs obtained. This algorithm is flexible and provides limitless combinations when paired with different encryption algorithms to encrypt the Sudokus. A recursive approach of the algorithm can be implemented on the Sudokus themselves, encrypting these Sudoku keys using this algorithm depending on security requirements. Another area of improvement in this algorithm is the differential attacks analysis, where the algorithm got slightly lower NPCR values than its competitors. The next possible area of improvement would be to improve this algorithm's encryption and decryption speeds by implementing it in a significantly faster processing language like Java or C++. Doing so can make it possible to use this algorithm for instant communication.
An essential parameter to determine an algorithm's usability is its time and space complexity and its resistance to different attacks. Future scopes would also involve testing this algorithm using the various uncommon attacks available in an attacker's arsenal and make this algorithm resilient to quantum computing attacks.

Disclosure statement
There is no financial or non-financial interest in publishing this work.

Notes on contributors
Kanaad Deshpande is a final-year computer engineering student at Dwarkadas Jivanlal Sanghvi College of Engineering, which is affiliated with the University of Mumbai. His major research interests include cryptography and cybersecurity, blockchain technologies, and machine learning.
Junaid Girkar is a final-year computer engineering student at Dwarkadas Jivanlal Sanghvi College of Engineering, which is affiliated with the University of Mumbai. He is fascinated by on-going research in the fields of cybersecurity, blockchain, machine learning, data mining, and Internet of Things.