Vigenère Cipher Algorithm Optimization for Digital Image Security using SHA512

One of the popular cryptographic algorithms is the Vigenère Cipher. This algorithm is included in classical cryptographic algorithms, so its capabilities are limited to text-type data. Through this research, this research try to modify the Vigenère Cipher so that it can be used on digital image media. The improvement is performed using ASCII code as a Vigenère table and the key generated by the SHA512 hash technique with salt. The encryption and decryption process was carried out on ten jpg and ten png files and showed a 100% success rate. Speed and memory consumption tests on the encryption process by comparing it with the AES algorithm show that AES excels in speed with 409,467 Mb/s while Vigenère wins in memory consumption by utilizing only 5,0007 Kb for every Kilobytes of the processed digital image file.


Introduction
Human activities lately are related to communication, data, and information [1]. Security is one crucial aspect that information or data should be achieved. The security issue is important because it relates to sensitive data by protecting it from unauthorized access, alteration, or deletion [2]. Data security has several aspects, including authentication, confidentiality/privacy, integrity, and non-repudiation. Some of these points can be solved using cryptographic techniques [3]. Cryptography is a method used to ensure data security through an encryption process so that the data becomes difficult to read or open by someone who is not authorized because they do not have the key to decrypt [4]. In other words, cryptography can change the contents of a data into other random data [5].
Cryptography is broadly classified into two types: classical cryptography and modern cryptography. One of the popular classical cryptography algorithms is the Vigenère Cipher. This algorithm implements a substitution technique, an encoding process, by changing the data contents based on the key used, so it becomes unreadable [6]. The Vigenère Cipher uses Vigenère squares in the encryption and decryption process, thus making this algorithm easily understood and implemented [3]. Figure 1 illustrates a Vigenère square.

Figure 1. Vigenère Cipher Tabula Recta Example
Cryptography has not only been used for text-based data but is also applicable to other kinds of data like images, videos, and sounds [7]. A cryptographic algorithm can be categorized as good if it maintains the secret aspect of an encrypted message and cannot be read by someone unauthorized to access the data [8].
Unsafe data or systems will undoubtedly have a harmful impact [8]. One method that can be used to maintain the confidentiality of data is to convert it into meaningless encrypted data. This process can be commonly referred to as cryptography [9]. Cryptography is described as a science and art of securing messages as they travel from a source to a destination. This process consists of three primary functions, among others [10]: a. Encryption is the process of converting the original message into codes that are difficult or even incomprehensible. b. Decryption is the reverse encryption process, changing the encrypted message into the original message. c. Key is a set of parameters used in the encryption and decryption processes.
Cryptography has several purposes on several security aspects as follows [3]: a. Confidentiality aims to prevent messages from being read by unauthorized parties. b. Data integrity aims to get guarantee that the message is still original/intact and not manipulated during delivery. c. Authentication aims to identify the truth of the parties communicating and the message's truth. d. Non-repudiation aims to avoid denial by the communicating parties.
Sinaga et al. combined the Vigenère Cipher algorithm with column transposition to build a strong encryption technique applied to digital image media. This study used a key generated by a random function that contains numbers ranging from 0 to 255 [7]. Gunadhi and Sudrajat, in their research, implemented a modified Vigenère Cipher to secure the patient's medical record data, making the patient's medical record data safer from attacks by cryptanalysts [9]. Mandal and Deepti conducted another study by implementing a multi-level encryption scheme. The method uses a key with the same character length as the plain text to produce the first cipher text. It doesn't stop here; the first cipher text is then encrypted again with the same key as the first cipher text to produce the second cipher text. In conclusion, compared to several other cryptographic algorithms (AES, Blowfish, and RC5), this method has difficult results for cryptanalysts to solve and has lower computational complexity, so it is suitable for lightweight applications and has limited resources [10].
Soofi et al. tried slightly modifying the Vigenère square table by changing the order of each character and adding an "&" character instead of a white space character. This method produces the Vigenère algorithm, which is more robust against attacks by the Kasiski and Friedman methods [11]. Some research on Vigenère Cipher has been conducted by combining it with other approaches, such as the Goldbach Codes compression technique. The merger results produce cipher text that is difficult to predict even using the Kasiski method attack because the resulting set of characters is different from the characters used in plain text [12].
The other combining technique uses encryption, key generation, and steganography. The encryption used is the Vigenère Cipher, modified using a Vigenère square composition according to the arrangement of letters, numbers, and symbols on the keyboard. Meanwhile, the key used is generated through a chaos function. The next process is to compress the encrypted data using Dictionary Based Compression. As the last step, the compressed data is hidden into a digital image using steganography with the Least Significant Bit (LSB) method [13]. Saputra et al. implement the Vigenère Cipher by utilizing a 5 x 5-pixel grayscale image as a key. This grayscale image key is transformed into ASCII characters, resulting in a character arrangement that can be processed into the Vigenère Cipher [14].
Another research that aims to compare the avalanche effect has been carried out by expanding the range of characters that can be accommodated to 128 pieces according to the number of standard ASCII characters and rotating the square matrix. The process implementation produces an avalanche effect value of around 45% to 49% [15]. In their research on the Vigenère Cipher implementation, Fadlil et al. developed a unique technique, merging Artificial Neural Networks (ANN) with Vigenère Ciphers. This study uses ANN as a key generator by entering the parameters of hidden neurons (K), input neurons (N), and weights (L) so that random characters are generated that can be used in the encryption and decryption process. Through this approach, it is claimed to have less possibility of generating the same key even if the same parameter value is entered repeatedly [16].
Hernawandra et al. use digital images in their research to secure data in the form of text by first carrying out the encryption process using Vigenère Cipher and substitution. The encrypted text produced by the encryption procedure is then hidden in digital image media using 4-bit LSB steganography. The output of this research is an application that runs on the Android platform. This research concludes that the built application can secure messages through the 4-bit LSB steganography method combined with substitution encryption and Vigenre Cipher and has an average avalanche effect of 12.77% [17].
There aren't many research projects on implementing Vigenère Cipher on digital image media. One is by substituting the color code for each pixel based on the key entered. As a result, another image with a random color is formed [18]. Another research is to do the encryption process twice using Vigenère Cipher and adopt an expansion key using the RC6 algorithm on text media. This study compares data size before and after encryption (avalanche effect) in several scenarios, such as using the standard Vigenère Cipher, merging with RC6 expansion keys, and others [19]. Riadi conducted similar research by first transforming a digital image with a base64 encoding method with a radix-64 character arrangement used as a Vigenère square. The encryption process was successful and took less than 0.2 seconds, and the decryption took less than 0.19 seconds on ten digital image samples [20].
Digital images are one of the most popular media types used to communicate online and in person [21]. Therefore, this study will use the Vigenère Cipher algorithm to develop digital image security. Previous research has not highlighted the usage of SHA512 as a key generation mechanism in conjunction with salt to prevent key attacks. This research will combine the SHA512 hash method as a key generator with ASCII code as a Tabula Recta. They proved the research results' validity by calculating the Peak Signal-to-Noise Ration (PSNR) between the original and decrypted files. This study will also present the time required for the encryption and decryption processes. Panda research shows that AES exceeds DES, RSA, and Blowfish in terms of encryption and decryption speed [22], so it was chosen as a benchmark cryptographic method in this research.
Furthermore, AES is one of the most extensively utilized modern cryptographic algorithms [23]. The test results will be compared with the AES algorithm regarding processing speed and the amount of resources or memory used. This research is expected to provide insight into the importance of securing data or files, especially digital image data.

Research Methods
This research implements the modified Vigenère Cipher algorithm and produces an output in the form of a console-based application. Modifications are made in the form of widening the character range according to the characters used by the ASCII code.

Vigenère Cipher
The Vigenère Cipher is a further development of the Caesar Cipher and is included in the category of polyalphabetic substitution cipher [24]. Vigenère Cipher can be performed in two ways: manually using a Vigenère square (tabula recta) as shown in Figure 1 or by number substitution (mathematical). Under standard conditions, encryption and decryption using the Vigenère Cipher can be stated as (1), while decryption can be written as (2). Ci = (Pi + Ki) mod 26 (1) Pi = (Ci -Ki) mod 26 (2) Here is an example of using the Vigenère Cipher based on the alphabetical arrangement, as shown in Figure 2.

SHA512
One of the hash functions is SHA (Secure Hash Algorithm). The NSA (National Security Agency) created this algorithm, which was then published by the NIST (National Institute of Standards and Technology) [25]. SHA has now reached the third generation called SHA2, which consists of SHA224, SHA256, SHA384, and SHA512 [26]. SHA has a one-way hash property as a hash function, which implies that it generates a hash result that cannot be decrypted. Another characteristic is that it is very sensitive to changes even though they are minor. Any changes to the input message will give different results [20] [24] [29].

ASCII Code
ASCII code is a set of codes that bridge the interaction between humans and computers. These codes are 8 bits long, ranging from 00000000 to 11111111. As a result, there are 256-character combinations ranging from 0 to 255 [30]. Text is usually presented by ASCII codes ranging from

Encryption Process
The process of transforming original data into encrypted data is known as encryption [3]. The encryption process is presented as a flowchart, as shown in Figure 4. The first step to starting the encryption process is to enter the key and the path to the location of the digital image file. Furthermore, the salt inputted key will be appended both in front of and behind the key, and the key will be converted to a SHA512 hash format. Then the application will perform the encryption process by applying the Vigenère Cipher, which uses a Vigenère table arrangement based on ASCII code and the hashed key. The encryption process is complete until that stage, and the results are issued as a file with the *.vig extension.

Decryption Process
Decryption is restoring encrypted data into original data [3]. The decryption process is presented in the form of a flowchart, as shown in Figure 5  The first step to decrypting is the user entering the encrypted file's key and path. First, the application will add salt both on the front and rear of the key, and the key will be converted to a SHA512 hash format. Then the application will perform the decryption and encryption process, namely applying the Vigenère Cipher using a Vigenère table arrangement based on ASCII code and the hashed key. Next, the application will return the encrypted digital image file into a digital image file according to the original format.

Vigenère Cipher Modification
This research uses a modified Vigenère Cipher. The modification was limited to widening the support characters from the original 26 alphabetic to 256 characters in the ASCII table. As a result, the formula for performing the encryption process has altered, as written in (3), whereas the formula for decryption is written in (4).

Ci = (Pi + Ki) mod 256
(3) The key generation procedure was also changed, with the entered key converted into a 128character hexadecimal character arrangement using the SHA512 hash method and the insertion of salt (extra characters). Adding salt to the key prevents the attacker from guessing the key [32]. Brute-Force Attack, Rainbow  [33]. Although adding salt does not ensure perfect key protection, it can make the computational process for key breaking infeasible [34].

Implementation
This research produces output from a console-based application built using the PHP programming language version 7.2.19. This application consists of two main files, namely encrypt.php and decrypt.php. While the main core for the encryption-decryption process uses only one file, namely VigenereCipher.php, which is in the source folder. An example of the display in the encryption process and the format of the command that is executed is shown in Figure 6.

Figure 6. Encryption process
To start this application, two arguments must be filled out, one for each encryption and decryption operation. The first parameter is a string that indicates the file's location to be encrypted or decrypted. The second parameter is the key used. An example of the encryption process using a digital image file in Figure 7 is shown below.
sha512("Th15 Iz Pr3-54lT" + "Play with Cryptography" + "tH1z i5 p0zT-sALt") Hashed Key 11bc66a87804925de939d4d2f682cca7db089df65934d223d8b97feec68e7 34c48e8b931a47f0a4ab6e888e3bed34ab9260e945bbcfd043b0edb40494d 064c37 The result of the encryption process is a file with a .vig extension format, while the result of the decryption process is a file with an extension format according to the initial format of the file. An example of the display in the decryption process is shown in Figure 7.

Testing
The test was carried out using hardware specifications as shown in Table 1 and running on the Windows 10 Pro 64-bit operating system. The validity of the research results was tested by calculating the Peak Signal-to-Noise Ratio (PSNR) value between the original and the decrypted file. The test is declared valid if the PSNR value shows an infinite value (zero errors) [35], with the results shown in Table 2. Table 2 shows that all files have an infinite value on PSNR testing, indicating that encrypted files were successfully decrypted into the original file without any changes. Table 3 shows the time needed for the encryption and decryption processes in ten png files. The chart shown in Figure 9 is based on Table 3 data. The chart shows almost no difference between the encryption and decryption process duration for the png file. The chart also shows that the larger the image size, the greater the time needed for encryption and decryption processes.  Table 4 shows the time needed for the encryption and decryption processes in ten jpg files. Table 3, Table 4 also shows that the larger the file size, the greater the time required for encryption and decryption processes. The chart is shown in Figure 10. Table 4 and Figure 10 also show no difference between the encryption and decryption process duration for the jpg file. Another test was conducted by comparing the speed of the encryption-decryption process and the memory resources used with one of the modern cryptographic algorithms, the Advance Encryption Standard (AES). The AES algorithm is categorized as symmetric cryptography and uses a block cipher scheme [29]. AES is a new security standard to replace the Data Encryption Standard (DES). This algorithm uses a symmetric key and has been used by the United States government [36]. Table 5 shows the comparison test results for speed for the encryption process between AES and Vigenère Cipher.

As in
Average speed both for the AES and Vigenère Cipher can be calculated using the data from Tabel 5. The AES has an average speed of 409,467 Mb/s, while the Vigenère Cipher has only 5,528 Mb/s. The comparison chart of the encryption process speed test between the AES algorithm and the Vigenère Cipher is shown in Figure 11. Figure 11 shows that The AES algorithm is significantly faster than the Vigenère Cipher algorithm. In fact, a file size of 10,949 KB only takes under one second, much faster than Vigenère Cipher, which takes about two seconds.   The comparison diagram of memory consumption for the encryption process between the AES algorithm and Vigenère Cipher can be seen in Figure 12. Figure 12 shows that the Vigenère Cipher outperforms the AES in memory consumption.

Conclusion
The Vigenère Cipher algorithm can be used to secure digital images by combining ASCII code and SHA512 as a key generator. Tests conducted on ten png files and ten jpg files showed that the larger the file size, the more time it takes for encryption and decryption.
The comparison test of speed and memory consumed in the encryption process between the AES algorithm and Vigenère Cipher shows that AES is much faster than Vigenère Cipher, even for large image files. However, the Vigenère Cipher managed to win in terms of memory consumption.