1 Introduction

Cryptography produces ciphers to secure communication between a sender and recipient, with objectives such as privacy, integrity, and access control. Encryption scrambles messages and decryption transforms them back to plain text. Cryptography algorithms are used to encrypt and decrypt data, with the primary objective of making it difficult to decode without the key. Testing each key combination is the most effective technique, but time-consuming. Cryptography algorithms are usually classified into two groups: symmetric key encryption and asymmetric key encryption.

  1. 1.

    Symmetric key encryption [1] uses a single key for both the encryption and decryption processes, as shown in Fig. 1. The key is first sent via a secure channel to the sender and receiver, and the strength of the encryption depends on the length of the key (in bits). Various techniques are used and researched in different fields for key distribution between the sender and receiver. Examples of symmetric key encryption algorithms include RC2, DES, 3DES, RC5, Blowfish, AES [2,3,4,5], and S-DES.

  2. 2.

    Asymmetric key encryption resolves the issue of key distribution in symmetric algorithms by using different keys for encryption and decryption, as shown in Fig. 2. This method employs two types of keys: private keys and public keys. The original data or plain text is encrypted using the public key to produce a cipher text. When the receiver receives this cipher text, they use their own private key to decrypt it. A private key is also referred to as a secret key since only the intended recipient or an authorized person is aware of it. However, public keys can be kept in open databases where anyone can access them. Examples of asymmetric key encryption methods include RSA [6, 7], Digital Signatures [8], and others [9,10,11,12,13,14,15,16,17].

Fig. 1
figure 1

Symmetric key encryption

Fig. 2
figure 2

Asymmetric key encryption

It is assumed that the encryption and decryption algorithm of a certain cryptography system is known to everyone. The level of security of the cipher text is determined by the secrecy of the key used for encryption and decryption.

The paper is structured as follows: the background work of symmetric and asymmetric key encryption schemes is discussed in Sect. 2, the proposed method is presented in Sect. 3, the performance of the proposed scheme is evaluated in Sect. 4, the security analysis of the proposed scheme is presented in Sect. 5, and the paper is concluded with potential future work in Sect. 6.

2 Background work

Symmetric key encryption has been an important technique for ensuring data security for a long time. Traditional symmetric encryption algorithms such as AES, DES, and 3DES have been widely used, performance of these algorithms discussed by Patel et al. [18]. However, these techniques are computationally intensive and have certain limitations in terms of the key size and complexity. Researchers have developed various lightweight and efficient symmetric encryption schemes to address these limitations. One of the common approaches to achieving lightweight encryption is to use simple operations such as XOR and permutation matrices, which are computationally efficient. For example, the Lightweight Block Cipher family (LBlock, LEA, and Piccolo) are lightweight ciphers that use simple operations such as bitwise XOR and permutation. These ciphers have shown good performance in terms of security and efficiency, making them suitable for resource-constrained devices. Another approach to lightweight symmetric encryption is to use variable-sized keys. The RC5 algorithm is an example of a symmetric encryption scheme that allows for variable key sizes. This technique enhances the security of the cipher by allowing for the use of larger key sizes while keeping computational complexity low. Table 1 shows the variety of symmetric key encryption with their advantages, disadvantages, or limitations.

Table 1 Literature survey of symmetric key encryption schemes

The proposed technique of symmetric key encryption using lightweight operations such as XOR and permutation matrices, and the use of variable-sized keys is a promising approach for achieving efficient and secure data encryption. The use of ASCII values for encryption and decryption is an added advantage, making it suitable for resource-constrained devices. Various other techniques such as LBlock, LEA, and RC5 have also shown good performance in terms of security and efficiency, making them suitable for use in different applications.

3 Proposed model

The proposed approach begins by transforming characters into their ASCII values before encrypting the plaintext into ciphertext through a series of steps. It utilizes two keys, \(k_1\) and \(k_2,\) as symmetric keys for both encryption and decryption. Although there is no limit on key length, a larger value is preferred for improved security. This algorithm covers the entire ASCII character set. The encryption and decryption methods of the proposed algorithm are discussed in detail in the subsequent steps of the algorithm. The detailed steps for plain text encryption are discussed in Algorithm 1 in the following sections. In Algorithm 1(i), the ASCII characters of a plain text encoded representation are shown. First, the plain text characters \({PT_1, PT_2,\ldots ,PT_l}\) are converted into ASCII decimal values. Next, the encoded numbers \({N_1, N_2,\ldots ,N_l}\) are generated by adding the value 1000 to these converted ASCII decimal values. To create the combined number CN,  all the encoded numbers undergo a string concatenation operation. In Algorithm 1(ii), the combined number CN is used as a row matrix along with the encryption key \(K_1\) to generate the encoded ASCII matrix \(\alpha .\) Here, \(k_1\) defines the number of columns in each row. The number of rows in the \(\alpha \) matrix is equal to \(len(CN) \mod K_1,\) where len(CN) represents the length of CN. Any unfilled columns are filled with bogus values. In Algorithm 1(iii), the \(\beta \) matrix is generated with the help of the private key pair \(K_1, K_2.\) In Algorithm 1(iv), the XOR operation is performed between the \(\alpha \) and \(\beta \) matrices, and the resulting matrix is added with the value 1000 to generate the \(\gamma \) matrix. In Algorithm 1(v), row-wise permutation is performed on the \(\gamma \) matrix using the \(\theta \) matrix, which generates the \(\gamma _r\) matrix. The \(\theta \) matrix contains the row permutation sequences for the row-wise permutation operation on the \(\gamma \) matrix. In Algorithm 1(vi), column-wise permutation is performed on the \(\gamma _r\) matrix using the \(\theta ^{\prime }\) matrix, which generates the \(\gamma _c\) matrix. The \(\theta ^{\prime }\) matrix contains the column permutation sequences for the column-wise permutation operation on the \(\gamma _r\) matrix. In Algorithm 1(vii), the ciphertext is generated by first subtracting the value 1000 from each element of the \(\gamma _c\) matrix. The resulting values are then converted into equivalent ASCII characters, which are assigned to ciphers \({C_1, C_2,\ldots , C_{p-1}, C_p},\) where p represents the number of rows in the \(\gamma _c\) matrix and \(q=K_1\) represents the number of columns. Finally, all the ciphers are concatenated to generate the ciphertext CT.

figure a

The detailed steps for decrypting the ciphertext are discussed in Algorithm 2 in the following sections. In Algorithm 2(i), the ASCII characters of the decoded ciphertext representation are shown. Here, the ciphertext characters \(CT_1, CT_2,\ldots ,CT_l\) are first converted into ASCII decimal values. The resulting numbers \(CTN_1, CTN_2,\ldots ,CTN_l\) are generated by adding the value 1000 to these converted ASCII decimal values. To create the combined ciphertext number CCN,  all the encoded numbers undergo a string concatenation operation. In Algorithm 2(ii), the combined number CCN is used as a row matrix along with the encryption key \(K_1\) to reconstruct the decoded ASCII matrix \(\gamma _r.\) Here, \(K_1\) defines the number of columns in each row. The number of rows are equal to \(len(CCN) \mod K_1,\) where len(CCN) represents the length of the CCN. In Algorithm 2(iii), column-wise permutation is performed on the \(\gamma _r\) matrix using \(\theta '\) matrix, which reconstructs the \(\gamma _c\) matrix. The \(\theta '\) matrix contains the column permutation sequences for the column-wise permutation operation on the \(\gamma _r\) matrix. In Algorithm 2(iv), row-wise permutation is performed on the \(\gamma _c\) matrix using \(\theta \) matrix, which reconstructs the plaintext matrix. The \(\theta \) matrix contains the row permutation sequences for the row-wise permutation operation on the \(\gamma _c\) matrix. In Algorithm 2(v), the private key pair \(K_1\) and \(K_2\) are used to generate the \(\beta \) matrix. In Algorithm 2(vi), the XOR operation is performed between the plaintext matrix and the \(\beta \) matrix, and the resulting matrix is subtracted by the value 1000 to reconstruct the \(\alpha \) matrix. In Algorithm 2(vii), the combined number CN,  which is a row matrix, is reconstructed by concatenating the elements of the \(\alpha \) matrix in a row-wise sequence. After that, for each group of combined numbers, the first four elements are concatenated and subtracted by the value 1000. The resulting values are then converted into ASCII character values and stored in variables \({PT_1, PT_2,\ldots ,PT_{p-1}, PT_p}.\) Finally, a concatenation operation is performed to reconstruct the plaintext value. Furthermore, the ciphertext is generated by first subtracting the value 1000 from each element of the plaintext matrix \(\gamma _c.\) The resulting values are then converted into equivalent ASCII characters, which are assigned to ciphers \({C_1, C_2,\ldots , C_{p-1}, C_p},\) where p represents the number of rows in the plaintext matrix and \(q=K_1\) represents the number of columns. Finally, all the ciphers are concatenated to generate the ciphertext CT.

figure b

4 Performance analysis

In performance analysis, we observed the computation complexity varying with different parameters and system specifications: The processor is an AMD A8-7410 APU (2.20 GHz), with 8.00 GB (6.91 GB usable) of DDR3 RAM, and a 64-bit Operating System (Windows 10 Pro), x64 based processor. The evaluation of the execution time includes the total time taken for encryption and decryption, as well as the time elapsed for file read and write operations in Java.

Table 2 shows the performance analysis based on sizes of the text file, by keeping the keys \(k_1\) and \(k_2\) fixed, total execution time (including both encryption and decryption) based on given parameter in below.

  • A plain text file is encrypted and then decrypted.

  • \(k_1 = 120\) and \(k_2 = 71.\)

Table 2 Computational complexity based on sizes of the text file

Figure 3 demonstrates that the line graph depicts the execution time of a proposed scheme based on the size of the text file (KB). Increasing the text file’s (KB) size results in a increased execution time.

Fig. 3
figure 3

Computational complexity based on sizes of the text file using line graph

Table 3 shows the performance analysis based on key size, by Keeping the key \(k_1\) fixed and applying the algorithm on the same file, variation of execution time with key \(k_1\) based on given parameter in below.

  • Size of the plain text file is 34.5 KB.

  • \(k_1 = 120.\)

Table 3 Computational complexity based on key \((k_1)\) length

Figure 4 shows how a proposed scheme’s execution time is represented by a line graph based on the length of the key \((k_1),\) where increasing the length of the key has no effect whatsoever on the execution time.

Fig. 4
figure 4

Computational complexity based on key \((k_1)\) length using line graph

Table 4 shows the performance analysis based on key size, by Keeping the key \(k_2\) fixed and applying the algorithm on the same file, variation of execution time with key \(k_2\) based on given parameter in below.

  • Size of the plain text file is 34.5 KB.

  • \(k_2 = 23.\)

Table 4 Computational complexity based on key \((k_2)\) length

Figure 5 shows how a proposed scheme’s execution time is represented by a line graph based on the length of the key \((k_2),\) where increasing the length of the key has no effect whatsoever on the execution time.

Fig. 5
figure 5

Computational complexity based on key \((k_1)\) length using line graph

Table 5 displays execution times for different key lengths of a particular encryption scheme, and the figure shows that the proposed scheme’s execution time is independent of key length. This is a significant advantage compared to other encryption schemes, which often experience longer execution times with longer key lengths. Moreover, the comparison table demonstrates limitations in block size, vulnerability to side-channel attacks, and limited adoption of some encryption schemes. As a result, the proposed scheme may offer better performance and security than these schemes.

Table 5 Comparison of symmetric encryption schemes

5 Security analysis

The proposed algorithm provides high level of security as an attacker would need to know both keys \((k_1\) and \(k_2)\) to decrypt the ciphertext and test all possible combinations. The length of keys is not limited, making it computationally infeasible for an attacker to attempt \(10^{170}\) times even for large key values like \(10^{50}\) and \(10^{120}.\) Using \(k_2\) as an exponent in both encryption and decryption procedures may increase the computing cost, but even for smaller values of keys, larger files will take significantly more time to execute. For optimal security, it is recommended to use keys with large values.

6 Conclusion and future scope

The proposed approach is a lightweight symmetric key encryption technique that uses permutation matrices and XOR operations for encryption and decryption with any key size, without increasing the computation complexity. The performance analysis demonstrated that larger key sizes provide higher security and that the size of the keys is completely independent of the execution time. However, the size of the file affects the execution time, meaning that as the text file size increases, so does the execution time.

The future work of the proposed algorithm includes modifying the functions used to generate the XOR matrix and permutation matrix to enhance the algorithm’s security. Additionally, optimizations can be implemented to improve the speed of encryption and decryption of larger text files. Overall, the approach provides a secure and lightweight encryption technique for textual data and has potential for further enhancements to improve its performance and security.