Performance Analysis of Two Famous Cryptographic Algorithms on Mixed Data

: The rapid development of digital data sharing has made information security a crucial concern in data communication. The information security system heavily relies on encryption methods. These algorithms employ strategies to increase data secrecy and privacy by obscuring the information, which only those parties who have the accompanying key can decode or decrypt. Nevertheless, these methods also use a lot of computational resources, including battery life, memory, and CPU time. So, to determine the optimal algorithm to utilize moving forward, it is necessary to assess the performance of various cryptographic algorithms. Therefore, this study evaluates two well-known cryptographies (RSA and ElGamal) using mixed data such as binary, text, and image files. CPU internal clock was used to obtain the time complexity used by both algorithms during encryption and decryption. The algorithms used CPU internal memory to obtain memory usage during the encryption and decryption of mixed data. Evaluation criteria such as encryption time, decryption time, and throughput were used to compare these encryption algorithms. The response time, confidentiality, bandwidth, and integrity are all factors in the cryptography approach. The results revealed that RSA is a time-efficient and resourceful model, while the ElGamal algorithm is a memory-efficient and resourceful model.


Introduction
Data security is the science and study of strategies for securing data from unauthorized disclosure and alteration in computer and communication systems.With the exponential increase in data communication and transfer volume and the proliferation, diversification, and intensity of malicious activities, the need to ensure and sometimes enforce data security has become even more urgent and critical (Li et al., 2022).Consequently, research activities in data security have evolved rapidly and have produced exciting developments in related application fields of computer security, such as cryptography.Cryptography is a technique for preventing illegitimate access to information and data.Cryptography is the act of securing data and information through encryption and decryption.It is always synonymous with transforming plain text (ordinary text, also referred to as simple text) into cipher text (a method called encryption), then back again as plain text (known as decryption) (Adeniyi et al., 2022).
The quick and broad adoption of different connectivity and communication methods like social networks and wearable devices among others, have made it easier for people to exchange information over the internet.Digital images are currently among the most significant pieces of information shared online, particularly on social media.shared in real-time (Khalil et al., 2021).The family of Elliptic Curve based Encryption (ECC) and the most popular encryption techniques Data Encryption Standard (DES), Advanced Encryption Standard (AES), Rivest Shamir Adleman (RSA) and have more criteria for the security of digital images (Oğraş and Türk, 2016;Nkandeu and Tiedeu, 2019).Images must be encrypted using traditional encryption techniques, which take more time, processing power, and high performance (Avasare and Kelkar, 2015).To create ways and methods of encrypting images that are strong and resistant to attacks of all kinds and can be executed quickly in real-time and other such things, it has become necessary to use other techniques and methods that are sensitive to and take into account the characteristics of images (Jan et al., 2022;Abutaha et al., 2022).As a result, many encryption algorithms have been developed based on various theories, including DNA computing (Liao et al., 2018;Zhang et al., 2013), neural networks (Maddodi et al., 2018), cellular automata (Khedmati et al., 2020), compressive sensing (Brahim et al., 2020), optical transformation (Kaur et al., 2020), quantum theory (Musanna and Kumar, 2020) and chaotic maps (Kaur et al., 2020;Niu et al., 2020;Pourjabbar Kari et al., 2021).More recently, there is also visually meaningful encryption (Huang et al., 2023;Ye et al., 2021), asymmetric image encryption (Ibrahim and Alharbi, 2020;Ye et al., 2022), and multi-image encryption (Ye et al., 2021).
Continually performed cryptanalysis of current chaotic image encryption techniques is done in addition to studying encryption algorithms to show the level of security and to expose weaknesses in the encryption algorithms.Particularly, several chaotic-based encryption algorithms have been defeated because they were unable to fend off a known or specific plaintext assault (Hu et al., 2017;Awotunde et al., 2022).Because of this, it is constantly necessary to develop new technologies and algorithms to defend digital images against these inventive attacks.The intricacy of an algorithm is the measure that evaluates the number of resources, such as time, space, energy, and so on, that the algorithm requires.It is a measure of how 'good' the algorithm is at solving the problem.It can also be described as the efficiency of the algorithm in terms of the amount of data the algorithm must process (Abdulraheem et al., 2021a).Typically, the complexity of an algorithm is a function that maps the input length/size to the number of main stages (time complexity) or specific storage positions (space complexity).Some algorithms are more efficient than others, so having metrics for comparing their efficiency will be necessary; therefore, this study aims to determine the time and space complexity of RSA and ElGamal cryptographic algorithms on mixed data (text, image, audio, and video) datasets.
Several studies have recently examined the performance evaluation of RSA and ElGamal cryptographic algorithms on text, audio, and image data.This section gives a detailed summary of studies conducted concerning the time and space complexity of RSA and ElGamal cryptographic algorithms.The methods applied are reviewed based on their relatedness to this study.Kayalvizhi et al. (2010), the authors worked on the performance and comparison of RSA and ElGamal cryptography algorithms by assessing their power productivity and network lifespan.The researcher used a group-based wireless network topology situation with NS2 to investigate the performance of the collection.The information was scrambled at the foundation node and the ciphertext was sent to the target node through the cluster heads.The power consumption of RSA and ElGamal algorithms was analyzed and showed that RSA uses fewer resources and thus improves the life of the network relative to ElGamal.From the findings, the RSA algorithm has improved support for wireless communications and absorbs 14.5 percent less power than the ElGamal algorithm.The study was limited to 10 sensor nodes of the wireless network.Arora et al. (2013) suggested introducing cryptographic algorithms in Java programming language to create safe cloud data by using diverse features to distinguish between symmetric and asymmetric techniques such as AES, DES, blowfish, and RSA.They reported that AES used the minimum time to execute cloud data.Blowfish used less memory consumption.DES has invested the least amount of time in cryptography.RSA has spent the most time in cryptography and the highest memory capacity.In another study (Boni et al., 2015), the authors suggested a novel methodology to enhance the Diffie-Hellman algorithm, thereby involving complicated calculations that increase the computational complexity when producing shared keys called the multipliers key exchange technique.They reported that the multiplicative key exchange is better than the Diffie-Hellman algorithm in terms of execution time, thus, needs few computations compared with the Diffie-Hellman algorithm.The new method is used when keys are generated frequently and faster instead of protection where systems are not complicated or have a reduced setup.Okeyinka (2015), the authors worked on RSA and ElGamal Algorithms computing speeds performance for securing, confidentiality, and authentication of text data.The researcher used an internal computer clock for both RSA and ElGamal to compare and determine the execution times of each input text data and which one of the two methods is more computationally effective.The implementation of the work was checked with text details in different sizes.The result showed that RSA is more computationally efficient than ElGamal, which makes it perform better than ElGamal.However, the limitation of this research work is that text data was used with a limited character size.Bhanot and Hans (2015), the authors evaluated the comparative analysis of encryption algorithms.AES, RSA, and DES encryption algorithms were implemented on audio and video files of different sizes to determine the encryption and decryption time.The result showed that AES is best in terms of encryption and decryption time compared with the performances of RSA and DES under the same condition.The study was limited to certain metrics for comparative analysis.Thu et al. (2019), the authors discussed the encryption and decryption time performance analysis of RSA and ElGamal public key cryptosystems.The researcher encrypted the plaintext (text, image, and audio) file with a public key for RSA and ElGamal and showed the encryption time comparison for the two algorithms.The result shows that RSA is about four times faster than ElGamal during the encryption process and RSA is faster than ElGamal during the decryption process.The result contradicted the previously reviewed works that ElGamal is faster than RSA during the decryption process.However, the comparison is only based on encryption and decryption time for text, image, and audio data.Sari et al. (2020) examined the comparative study of LUC, ElGamal, and RSA algorithms in encoding texts.The study implements each algorithm using several texts to determine the encryption and decryption time.The result showed that the RSA algorithm performed better in text file encryption process time, while the LUC algorithm performed better in decryption.The work was limited to encrypting the secret message in text form.Desai et al. (2022), the authors examined several asymmetric public key cryptosystems.The research is comprehensive and subtle and it analyzes asymmetric public-key cryptosystems focused on performance-based criteria and metrics.The research entails a thorough, comparative, and in-depth examination of the RSA, ElGamal, and ECC-ElGamal public key cryptosystems.The study aims to produce clear conclusions on the performance requirements of the algorithms under consideration.
In another development, (Parenreng and Wahid, 2022) proposed using the ElGamal encryption model to distribute the symmetric key.The AES encryption model is a fairly secure algorithm to protect message data or confidential information.The study implemented cryptography algorithms in the email system, which was used to encrypt messages and data to be sent via email effectively and efficiently.The study aimed to address email security problems, especially regarding data leakage when sending emails via email.
Advanced security techniques are strictly desired to ensure the security of user information through these safetylimited channels.However, the existing encryption systems cannot guarantee the user data's security and authentication on these online platforms.Hence, Certificate Group Signcryption Systems (CGSS) are necessary.Meshram et al. (2021) uses conformable chaotic maps.This research provides an effective electronic currency (CCM) system based on CGSS.According to the study, any group signcrypter would work with the group 697 manager to encrypt information or data (GM) and send it to the verifier, who uses the group's public criteria to verify the veracity of the sign-encrypted information/data.Furthermore, the CGSS-CCM ECS scheme's traceability, unforgeability, unlikability, and robust security have all been created using computationally challenging problems.The study's performance evaluation demonstrates that it is resistant to the indiscernible chosen cipher text attack.Meshram et al. (2022) proposed a novel lightweight speck cryptographic algorithm to enhance the security of cloud computing for healthcare data.Unlike the cryptographic techniques frequently used in cloud computing, the exploratory findings of the suggested methodology demonstrated a high degree of security, a clear enhancement in the speed at which data is encrypted, and the level of security that may be attained.
Similarly, Abdulraheem et al. (2021b) suggested a simple, provably secure certificateless method for group oriented signcryption (CGST) using Fractional Chaotic Maps (FCM).Any group signcrypter may encrypt data or information with the Group Manager (GM) and have it delivered to the verifier without interruption using the CGST-FCM protocol.When used in real-time security applications, the network security from the study demonstrates appreciable consistency and high efficiency.Finally, Kaur et al. (2020) proposed an enhanced lightweight cryptography algorithm to secure IoT-based environments from attackers.Results indicate that the algorithm is more effective and safer in an IoT-driven setup, making it better suited for data security.Oladipupo et al. (2023) proposed a WSN paradigm that uses multicore WS clustering.The current Elliptic Curve Cryptographic (ECC) technique is enhanced for security against simple assaults and parallel execution of the encryption and decryption procedures.The key exchange mechanism was Elliptic Curve Diffie-Helman (ECDH) and the communication nodes were authenticated using Elliptic Curve Digital Signature Algorithm (ECDSA).Analyses of the model's security and performance compared to others were shown.

Materials and Methods
This study implements RSA and ElGamal cryptographic algorithms to obtain Encryption time, Decryption time, and the memory usage of both algorithms on mixed datasets.The data used were extracted from various data repositories such as (lipsum, datahub, Kaggle, and random text generators).Figure 1 displays the framework that was used in this study.The framework shows the phases involved in developing the models, including loading mixed data for processing encryption and decryption with RSA and ElGamal cryptographic algorithm for further analysis like time and space complexities.

Fig. 1: Conceptual framework of the study
Figure 1 shows the Hierarchical Input Process Output (HIPO) of the study.This displays the stages involved in obtaining the desired result of this research.The mixed data which includes (text, image, audio, and video) are the input tools in the study.The second stage of the framework is the process tool which includes RSA and ElGamal cryptographic algorithms to scramble the input data into unreadable content.The third stage is the result stage, which displays the complexities of each of the algorithms used.Finally, the time and memory usage of RSA and ElGamal are obtained and their performance is compared to determine which algorithms perform better on mixed data:

Key generation
The key generation process is detailed below: 1. Get two integers, p and q from the user.2. Check if p and q are prime.
2.1 If prime, continue the process, else exit the code 3. Calculate ( 1) * ( 1) pq  and name it The values of (p, q), and (n) are private.'e' is the public or encryption exponent.'d' is the private or decryption exponent.

Encryption and decryption
Given the message to be M and Cipher

Performance Analysis Measurement Factors
In this study, the following factors are used as encryption efficiency criteria.
Encryption time: This is the running time the algorithm used throughout the encryption of mixed data, this is obtained through the computer internet clock.
Decryption time: This is the time taken during the decryption of mixed Encryption memory: This factor is related to the amount of computer internet memory used during the mixed data encryption process.
Decryption memory: This factor is related to the amount of computer internet memory used during the decryption process of mixed data.
CPU internal clock: This is used to obtain the encryption and decryption time for all the categories of data.
CPU internal memory: This is used to obtain the memory space used by both algorithms during the encryption and decryption of all categories of data.
According to Fig. 3, the bigger the text data supplied to the program, the higher the space consumed by the RSA algorithm.This shows that the RSA algorithm consumes more CPU internal memory while encrypting text data than the ElGamal algorithm.
Table 2 shows the decryption time and memory usage of RSA and ElGamal cryptographic algorithms on the test dataset.
According to Fig. 4, the RSA algorithm consumes the CPU time during the decryption of text data while ElGamal consumes less CPU time during the decryption of text data.
In terms of memory usage, both algorithms consume an equal volume of CPU internal memory to decrypt text data.
Table 3 displays the data obtained from encrypting image data using RSA and ElGamal cryptographic algorithms.
Image data was supplied as input and the RSA and ElGamal algorithms were executed on it.Figure 6 shows that the RSA algorithm uses a lesser CPU internal clock while encrypting image data than the ElGamal algorithm, which employs more CPU internal clocks.
Figure 7, the output shows that the ElGamal algorithm outperforms the RSA algorithm in terms of CPU internal memory consumption.ElGamal consumes less memory during image data encryption than the RSA algorithm.
Table 4 shows the data generated from image data decryption using RSA and ElGamal cryptographic algorithms.
The elGamal algorithm also outperforms the RSA algorithm during the decryption of image data.For example, Fig. 8 shows that ElGamal consumes less CPU memory space during the image data decryption compared to the RSA algorithm.
According to Fig. 9, both ElGamal and RSA algorithms consume the same amount of CPU internal memory space during the decryption of image data.
Table 5 shows the data generated from audio data encryption using RSA and ElGamal algorithms obtained from the CPU's internal clock and memory.The result of Fig. 10 shows that audio data was inputted into the program and RSA produced a better result in terms of CPU time.RSA uses a lesser CPU internal clock for audio data encryption than the ElGamal algorithm.
The analysis of Fig. 11 shows that the ElGamal algorithm outperforms the RSA algorithm in terms of CPU memory usage during audio data encryption.In addition, the ElGamal algorithm consumed lesser CPU memory for audio data encryption than the RSA algorithm.
Table 6 shows the decryption time and memory usage obtained during the decryption process of audio data with RSA and ElGamal cryptographic algorithms.
From the analysis of time using audio data, ElGamal uses less CPU time in decrypting audio data than the RSA algorithm, which consumes more CPU time during the decryption of audio data.Also, Fig. 12 shows that the larger the audio size, the higher the CPU time consumption interval between the two algorithms.
The analysis of Fig. 13 shows that there is no significant difference in the amount of CPU space consumed by both algorithms, irrespective of the file size.
Table 7 shows the time and space generated during the encryption of video data with RSA and ElGamal cryptographic algorithms.
The analysis from Fig. 14 shows that video data was inputted into the program.The result indicated that the RSA algorithm consumes less CPU internal time during the video data encryption and the interval between the two algorithms increases as the video data size increases.
The analysis from Fig. 16 shows that RSA consumes more CPU internal memory during video data encryption.At the same time, the ElGamal algorithm outperforms the RSA algorithm in terms of CPU memory consumption.
Table 8 gives the generated data from decrypting video data with RSA and ElGamal Cryptographic algorithms.

Discussion
Internet devices are sophisticated, intelligent infrastructures made up of numerous self-organizing gadgets.In this case, the gadgets are used to analyze the network and send crucial information via the internet.Because of the potential for numerous attacks in this vast network from unidentified devices, data security and privacy are of utmost importance.The main drawback of the IoT network is that because the devices run on batteries, they have a limited capacity for internal storage.To address the issues caused in the network, it is vital to find more resourceoptimized and security-related solutions.Also, the complexity of the cryptographic methods requires the devices' resources to be consumed at a faster rate.Along with data integrity, it is also vital to determine the best cryptographic method for an automated IoT network.
Therefore, this study compared two prominent cryptographic methods with their operational behavior.On a laptop running Windows 10 64-bit, an i7 processor running at 2.23 GHz, and 8 GB of RAM, the simulation was run.As the test subjects, random sizes of files 22, 80, 5, 120, 140, 230, 2048, and 5120 were generated.The preferred language for implementation was the c-sharp programming language.The key sizes used were 128 bits, 64 bits, and 128 bits for the Cipher Block Chaining (CBC) mode of the two algorithms.Ten rounds of encryption and decryption were performed on each data block and the time requirements for each run were recorded.
The experimental results obtained from all the datasets used (text, image, audio, and video), as displayed in the tables and figures showed that the RSA algorithm outperformed the ElGamal algorithm during the encryption time of all categories of the dataset as regards the usage of CPU internal clock for text, image, audio, and video file sizes.This is under the existing works of literature (Thu et al., 2019;Sari et al., 2020;Desai et al., 2022;Parenreng and Wahid, 2022).ElGamal algorithm outperformed the RSA algorithm during the decryption time of all categories of data.This is consistent with the existing pieces of literature (Boni et al., 2015;Thu et al., 2019;Parenreng and Wahid, 2022;Meshram et al., 2021;AbdulRaheem et al., 2021c).It was observed that the RSA algorithm generated large files and consumed more space (memory) during the encryption process of all categories of text, audio, image, and video data concerning the CPU's internal memory usage.This is consistent with the existing literature (Meshram et al., 2022;Abdulraheem et al., 2021a;Oladipupo et al., 2023).ElGamal algorithm outperformed the RSA algorithm in terms of memory usage.It was also observed that both RSA and ElGamal algorithms consumed similar computational space for decrypting mixed data (Gadde et al., 2023;Ullah et al., 2023).
Therefore, this study used CPU internal clock and CPU internal memory for time and space performance metrics to evaluate which of the RSA algorithm and the ElGamal algorithm performs better when it comes to mixed data.Based on the various experimental results generated, it was observed that the RSA algorithm is time efficient.In contrast, the ElGamal algorithm is a memory-efficient algorithm for all categories of data.The performance of RSA and ElGamal algorithms was evaluated in the current work.Future work can be performed using other performance evaluations like throughout, accuracy, precision, recall, etc., on encryption and decryption of both algorithms.The comparative analysis of other faster cryptographic can experiment on text, audio, and video as well.In future work, various compression algorithms can be used before encryption to increase the speed of both algorithms further

Conclusion
The RSA and ElGamal cryptographic algorithms were implemented to determine the time and space complexity of both algorithms on mixed (text, image, audio, video) data.The experimental results showed that the RSA algorithm performs better in time complexity for all categories of the dataset (text, image, audio, and video) during the encryption process.Furthermore, the RSA algorithm is better regarding time complexity during the decryption of mixed data.On the other hand, the ElGamal algorithm performs better in terms of memory consumption for encryption and decryption processes for all the dataset categories.Based on the comparative analysis of the time and space complexity of both RSA and ElGamal algorithms, it was discovered that RSA is a better algorithm for time complexity.That is, RSA can be said to be a time-efficient algorithm.On the other hand, the ElGamal algorithm performed better than RSA in the memory usage aspect.Therefore, the ElGamal algorithm is said to be a memory-efficient algorithm.This study provides an addition to the body of knowledge by investigating the performance of selected cryptographic algorithms (RSA and ElGamal) in terms of computer resource usage (time and memory) on mixed data.This seeks to enhance decision-making on which algorithms perform better concerning time and memory usage and the design of a high-impact computer system.Furthermore, the study encourages using additional performance metrics for both algorithms or adding more algorithms to the existing works.
random prime number (p) Choose a generator number (a) Choose an integer (x) less than (p-2), as the secret number Compute (d) where (d) = a x mod p The private key is given as (x) and the public key as (p, a, d) Encryption and decryption Represent the plaintext as an integer m where: 0 < m < p-1 Encryption is done using the public key (p, a, d) Choose an integer k such that: 1 < k < p-2 Compute y, y = a k mod p Compute z, z = (d k * m) mod p The ciphertext is given as C = (y, z) Decryption is done using the private key (x) The receiver obtains the ciphertext C = (y, z) Compute (r) as follows: r = y (p-1-x) mod p Recover the plaintext as follows: m = (r * z) mod p

Fig. 2 :
Fig. 2: Encryption time analysis for RSA and ElGamal cryptographic algorithms for text dataset

Fig. 3 :Fig. 4 :Fig. 5 :Fig. 6 :
Fig. 3: Analysis of memory used for RSA and ElGamal for text dataset during the encryption process

Table 1 :
Tabular representation of text data encryption for RSA and ElGamal algorithms Time of encryption Space of encryption -

Table 2 :
Tabular representation of text data decryption for RSA and ElGamal algorithms

Table 3 :
Image data encryption for RSA and ElGamal algorithms Time of encryptionSpace of encryption -

Table 4 :
Image data decryption for RSA and ElGamal algorithms

Table 5 :
Encryption time and space usage of RSA and ElGamal for audio data Table1displays the time and space used to encrypt the text dataset using RSA and ElGamal cryptographic algorithms.

Table 6 :
Decryption time and memory usage of RSA and ElGamal for audio data Decryption time Decryption memory usage -

Table 7 :
Encryption time and space usage of RSA and ElGamal for video data

Table 8 :
Decryption time and space usage of RSA and ElGamal for video data Video data decryption time (s) Video data memory usage (decryption) (kb) -