1 Introduction

In light of the rapid advancement of the Internet, an immense volume of information is incessantly transmitted on a daily basis. The complexity and openness of the Internet have posed significant threats to the security of information transmission. Digital images, serving as a ubiquitous information carrier, find widespread applications in various domains, including daily life, social media, and medical imaging, owing to their intuitive and straightforward nature [1,2,3,4]. Consequently, the security of digital image transmission has become paramount. To prevent unauthorized access or theft of images during transmission, encryption is commonly employed to safeguard the information contained within the image [5,6,7].

Chaotic systems exhibit characteristics such as randomness, sensitivity to initial values, and unpredictability, making them suitable for image encryption [8, 9]. These systems commonly used for image encryption can be categorized into low-dimensional chaotic systems and high-dimensional chaotic systems [10, 11]. Examples of low-dimensional chaotic systems include the classical one-dimensional Logistic map and Sine map [12,13,14]. On the other hand, high-dimensional chaotic systems encompass well-known models such as the two-dimensional Hénon map, three-dimensional Lorenz system, and Chen system [15,16,17,18,19]. Both low-dimensional and high-dimensional chaotic systems have their respective advantages and disadvantages. Due to their relatively simple mathematical models, low-dimensional chaotic systems are easy to realize and comprehend, with lower running time costs [20]. Conversely, high-dimensional chaotic systems may possess more intricate mathematical models, resulting in complex chaotic behavior that is challenging to implement and incurs relatively higher running time costs [21,22,23]. A comparison reveals that it is impractical to use a specific index to determine which dimension of a chaotic system is superior. In recent years, many scholars have proposed various improved one-dimensional chaotic mappings based on the Logistic map and Sine map, such as the Sine-logistic integrated map (SLIM) [24] and Logistic-Sine map [25]. These chaotic systems have shown some improvements compared to the Logistic map and Sine map in terms of performance. However, they still have some drawbacks. For example, SLIM has a relatively large periodic window, while Logistic-Sine map have a limited parameter range, thereby restricting their chaotic performance to some extent. Therefore, in order to further improve these shortcomings, this paper presents a new one-dimensional chaotic system. Compared with the aforementioned chaotic systems, through some performance analysis, it is concluded that this chaotic system has a larger parameter range and better chaotic behavior.

At present, mainstream encryption algorithms are generally categorized into two stages: scrambling and diffusion [26,27,28]. Scrambling is designed to make information in the image challenging to comprehend and analyze by perturbing the position of pixels. Classical scrambling algorithms encompass the Arnold transform [29,30,31], standard zigzag scrambling [32, 33], and the Fisher-Yates algorithm. While these algorithms exhibit different encryption effects, they each have inherent drawbacks. For instance, the Arnold transformation displays periodic characteristics, allowing the image to be restored to its original state after a certain number of transformations [34, 35], posing security risks in the encryption process. Standard zigzag scrambling, requiring multiple iterations, retains specific values in the matrix unchanged, resulting in prolonged processing times and incomplete data scrambling. Diffusion involves altering pixel values in the image to distribute information more evenly, thereby enhancing the overall encryption effect. The XOR operation is a standard method in the diffusion stage. Wang et al. [36] integrated chaotic sequences with the traditional Josephus sequence to enhance sequence randomness and confusion effectively. However, the unchanged step size of the Josephus algorithm imposes limitations on improving sequence randomness. Xie et al. [37] proposed an improved Josephus algorithm that dynamically selects different directions and step sizes in each iteration, significantly enhancing the randomness of the scrambling process but at the cost of longer encryption time. Wang et al. [38] designed and utilized a new dynamic Josephus permutation algorithm that recalculates random counting intervals each round and utilizes chaotic sequences generated by chaotic systems to obtain these intervals. Although randomness is guaranteed, it also faces the issue of prolonged permutation time. Setiadi et al. [39] performed permutation on all bit pixels based on Josephus sequences, where Josephus sequences are dynamically determined according to the pixel coordinate positions, reducing permutation time but with limited effectiveness. Through the aforementioned analysis, this paper proposes a more secure and efficient image encryption algorithm. Initially, the image is partitioned into uniform and appropriately sized blocks. The chaotic sequence generated by the chaotic system is sorted to create an index, which is then used for inter-block scrambling. Subsequently, the dynamic Josephus algorithm, guided by the chaotic sequence, is employed for in-block scrambling of each block. The standard zigzag algorithm is then applied for global scrambling of the image, resulting in a semi-encrypted image. Finally, the image undergoes rapid diffusion using the proposed diffusion formula to further enhance the encryption effect, producing the final encrypted image. This algorithm, combining block scrambling and the dynamic Josephus algorithm, reduces encryption time while achieving initial global scrambling of the entire image. The dynamic Josephus algorithm, an improvement over the traditional version, enhances scrambling randomness. Notably, the shortcomings affecting pixels in the original image's starting and ending positions do not impact subsequent standard zigzag scrambling, further enhancing the overall scrambling effect.

The main contributions of this paper are as follows:

  1. 1.

    A new one-dimensional Sine-Logistic chaotic system(SLCS) is proposed, which has a more significant parameter range and better chaotic behavior.

  2. 2.

    A new dynamic Josephus algorithm is proposed, which combines block scrambling and dynamic Josephus algorithm to scramble the entire image.

  3. 3.

    A new diffusion formula is designed, which combines two chaotic sequences with control parameters and initial values to spread the image rapidly.

The remaining structure of this paper is as follows. Section 2 introduces the proposed chaotic system SLCS and analyzes its performance in detail. Section 3 describes the steps of the encryption and decryption algorithm based on SLCS. Section 4 is the simulation results of gray images and various security analyses. Section 5 gives the simulation results of color images and various security analyses. Section 6 is the conclusion.

2 SLCS and performance analysis

2.1 Logistic map

The Logistic Map is a one-dimensional discrete dynamical system proposed by biologist Robert May in 1976 [40], and it stands as one of the classic examples in chaos theory. This mapping describes a simple yet nonlinear dynamical system, commonly used to demonstrate chaotic behavior and the complex evolution of systems under parameter changes. The mathematical expression of the Logistic Map is as follows:

$$x_{n + 1} = 4\mu x_{n} (1 - x_{n} )$$
(1)

where xn ϵ (0, 1) and μ ϵ [0, 1]. When μ ϵ (0.8972,1], the Logistic map exhibits chaotic behavior. The bifurcation diagram of the Logistic map is shown in Fig. 1a.

Fig. 1
figure 1

The bifurcation diagrams: a Logistic map; b Sine map

2.2 Sine map

The Sine Map is also a classic one-dimensional chaotic system, known for its relatively simple structure. The mathematical expression of the Sine Map is as follows:

$$x_{n + 1} = \mu \sin (\pi x_{n} )$$
(2)

where xn ϵ (0, 1) and μ ϵ [0, 1]. When μ ϵ (0.8722, 1], the Sine map exhibits chaotic behavior. The bifurcation diagram of the Sine map is shown in Fig. 1b.

2.3 SLCS

By analyzing the bifurcation diagrams of the Logistic map and the Sine map, it can be inferred that their parameter ranges are relatively small, and their chaotic behaviors are relatively simple. Building upon the mathematical expressions of the Logistic map and the Sine map, this paper proposes a new one-dimensional Sine-Logistic chaotic system (SLCS). The mathematical expression of this chaotic system is as follows:

$$x_{n + 1} = \left| {\sin (\mu \pi (x_{n} + 3)\sin (\pi x_{n} )(1 - \sin (\pi x_{n} ))2^{10} } \right|$$
(3)

where μ is the control parameter. When μ ϵ (0, + ∞), SLCS is in a chaotic state. The values of the chaotic sequences generated by SLCS are uniformly distributed in the interval (0, 1).

2.4 Performance analysis of SLCS

To demonstrate the pseudo-randomness, unpredictability, and other chaotic properties of the output sequence of SLCS, several experiments were conducted to analyze its dynamic behavior. Tests include bifurcation diagrams, sensitivity analysis, Shannon entropy, and so on.

2.4.1 Bifurcation diagram

Bifurcation diagrams are typically used to illustrate how the periodic behavior of a chaotic system evolves with changes in a parameter, leading to bifurcations, chaos, or other complex chaotic behaviors. The better the performance of a chaotic system, the more uniform the distribution of the generated chaotic sequence, and there are almost no occurrences of periodic windows [41]. The bifurcation diagrams of SLCS and other chaotic systems are shown in Fig. 2. From Fig. 2a, it can be observed that SLCS does not exhibit any periodic windows, and the generated chaotic sequence is uniformly distributed in the interval (0, 1). To demonstrate that the control parameter μ of SLCS ranges from (0, + ∞), the upper limit of μ is set to 1000. The bifurcation diagram of SLCS obtained with this upper limit for μ is shown in Fig. 2b. Similarly, from Fig. 2b, it can be seen that SLCS exhibits good chaotic behavior.

Fig. 2
figure 2

The bifurcation diagrams: a SLCS with μ ϵ (0, 1); b SLCS with μ ϵ (0, + ∞); c SLIM with r ϵ (0, 4); d Logistic-Sine map with β ϵ (0, 4)

2.4.2 Sensitivity analysis

Chaos systems are highly sensitive to initial conditions. In a good chaotic system, even small variations in initial values will lead to completely different chaotic sequences. The sensitivity of a chaotic system can be measured using Lyapunov Exponents (LE). It represents the numerical characteristic of the average exponential divergence rate of neighboring trajectories in phase space [42]. The Lyapunov exponent is calculated as follows:

$$LE = \mathop {\lim }\limits_{n \to \infty } \frac{1}{n}\sum\limits_{i = 0}^{n - 1} {\ln \left| {f{\prime} (x_{i} )} \right|}$$
(4)

where i represents the time series, and f(x) represents the equation of the chaotic system being used. When the value of LE is negative, it indicates that the system is in a contracting state. When the value of LE is positive, it indicates that the system is continuously folding and expanding. Therefore, the system is in a chaotic state only when LE is positive. The LE values of SLCS and other chaotic systems are shown in Fig. 3a. From the graph, it is evident that the LE value of SLCS is greater than that of other chaotic systems and is greater than 0. Furthermore, to demonstrate that the control parameter μ of SLCS can be stretched to infinity, Fig. 3b shows the chaotic state of SLCS with μ ranging within 1000. The LE value of SLCS is always greater than 0 and shows a continuous increasing trend. Therefore, when μ ϵ (0, + ∞), SLCS is chaotic.

Fig. 3
figure 3

Lyapunov exponent: a SLCS, Logistic map, Sine map, SLIM and Logistic-Sine map with μ ϵ (0, 1); b SLCS with μ ϵ (0, + ∞)

In addition, to further evaluate the sensitivity of SLCS to initial values, the output sequences were compared based on the increase in the number of iterations. Two extremely close initial points were selected, and the trajectories of the two chaotic sequences Fn(x0) and Fn(x0 + 10–14) were plotted over 40 iterations (the first 1000 iterations were discarded to eliminate transient effects). The results are shown in Fig. 4. From the graph, it can be seen that when the control parameter remains constant, small variations in the initial values result in completely different chaotic sequences generated by SLCS. Therefore, SLCS exhibits a high sensitivity to initial values.

Fig. 4
figure 4

Sensitivity of SLCS (x0 = 0.52878, μ = 0.747) to 10−14 change in the initial value

2.4.3 Shannon entropy

The Shannon entropy (SE) reflects the degree of chaos in the chaotic sequence generated by chaotic systems [43]. A higher SE value indicates a more complex and disordered chaotic sequence generated by the chaotic system, while a lower SE value suggests a simpler and more ordered sequence. Figure 5 illustrates a comparison of the Shannon entropy of SLCS with other chaotic systems. It is evident from the graph that the SE value of SLCS is higher and more stable, demonstrating its superior chaotic and stochastic properties, resulting in a more disorderly generated chaotic sequence.

Fig. 5
figure 5

Shannon entropy: SLCS, Logistic map, Sine map, SLIM and Logistic-Sine map for μ ϵ [0, 10]

2.4.4 The NIST SP800-22 test

To validate the applicability of the proposed chaotic system in designing image encryption algorithms, we conducted randomness tests on the output sequences of SLCS according to the National Institute of Standards and Technology (NIST) SP800-22 standard. The NIST SP800-22 standard comprises 15 sub-tests, each generating a P-value. We tested sequences with a length of 225 bits, aiming to generate P-values within the range [0.01, 1] to pass the corresponding sub-tests. The test results are presented in Table 1, demonstrating that the binary sequences generated by SLCS successfully passed all sub-tests. This indicates that SLCS can produce non-periodic output sequences with strong pseudo-randomness, thus making it suitable for image encryption.

Table 1 NIST test results

3 Encryption algorithm and decryption algorithm

This section provides a detailed description of the steps involved in the encryption and decryption algorithms based on SLCS. The encryption algorithm is primarily divided into four stages. The first stage is key generation, where the SHA-512 hash function is employed to process the plaintext image, and the processed result is transformed to serve as the algorithm's key. The second stage involves block permutation, wherein the chaotic sequences generated by SLCS are utilized to perform inter-block permutation and intra-block dynamic Josephus permutation on the plaintext image. The third stage encompasses global permutation, utilizing the zigzag algorithm to perform a single global permutation on the image. The fourth stage is diffusion, employing the proposed diffusion formula to rapidly diffuse the semi-encrypted image to obtain the final ciphertext image. Figure 6 intuitively illustrates the entire encryption process.

Fig. 6
figure 6

Encryption flow chart

3.1 Key generation

This paper selects the SHA-512 hash function as the primary method for key processing. The SHA-512 hash function possesses high resistance to decryption, with its forward operation being simple and efficient, while its reverse operation is extremely difficult. Regardless of the size of the input image, the output generated by SHA-512 is always 512 bits (64 bytes). The sensitivity of this function to the initial value implies that different image inputs will yield unique results. Consequently, the key generated by SHA-512 is closely related to the input plaintext, greatly enhancing the system's resistance to known-plaintext attacks and chosen-plaintext attacks. The initial values and control parameters of SLCS are determined by the key, and the block sizes m and n are also determined by the key. Using the plaintext image P as the input for the SHA-512 algorithm, a 128-bit hexadecimal string is generated, which is then converted to a 512-bit binary number K. K is divided equally into 16 groups k1-k16, each consisting of 32 bits. k1-k16 are processed according to Eq. (5)–(6), resulting in four sets of initial values and control parameters (x1, μ1), (x2, μ2), (x3, μ3), (x4, μ4). The block sizes m and n are obtained using Eq. (7)–(8).

$$x = \left\{ \begin{gathered} x_{1} = bi2de(k_{1} \oplus k_{9} )/2^{32} \hfill \\ x_{2} = bi2de(k_{2} \oplus k_{10} )/2^{32} \hfill \\ x_{3} = bi2de(k_{3} \oplus k_{11} )/2^{32} \hfill \\ x_{4} = bi2de(k_{4} \oplus k_{12} )/2^{32} \hfill \\ \end{gathered} \right.$$
(5)
$$\mu = \left\{ \begin{gathered} \mu_{1} = bi2de(k_{5} \oplus k_{13} )/2^{32} \hfill \\ \mu_{2} = bi2de(k_{6} \oplus k_{14} )/2^{32} \hfill \\ \mu_{3} = bi2de(k_{7} \oplus k_{15} )/2^{32} \hfill \\ \mu_{4} = bi2de(k_{8} \oplus k_{16} )/2^{32} \hfill \\ \end{gathered} \right.$$
(6)
$$m = \bmod (bi2de(x_{1} \oplus x_{3} \oplus \mu_{1} \oplus \mu_{3} ),\;5) + 2$$
(7)
$$n = \bmod (bi2de(x_{2} \oplus x_{4} \oplus \mu_{2} \oplus \mu_{4} ),\;5) + 2$$
(8)

where x ⊕ y represents the XOR operation between x and y, mod(x, y) represents the modular operation between x and y, and bi2de(x) represents the conversion of binary x to decimal number.

3.2 Encryption process

The encryption process is divided into two processes: scrambling and diffusion.

3.2.1 Scrambling process

The purpose of this process is to alter the pixel positions of the plaintext image. Let's assume the size of the plaintext image P is M × N. The specific permutation steps are as follows:

Step 1. To divide the plaintext image P into equally sized blocks, we pad P with pixels of value 300 to convert it into an image Pb of size Mb × Nb, where Mb and Nb are the minimum multiples of m and n, respectively. The calculation of Mb and Nb is shown as Eqs. (9)–(10).

$$M_{b} = M + m - \bmod (M,\;m)$$
(9)
$$N_{b} = N + n - \bmod (N,\;n)$$
(10)

Step 2. Calculate the number of row blocks mb and column blocks nb after partitioning Pb according to Eq. (11)-(12).

$$m_{b} = M_{b} /m$$
(11)
$$n_{b} = N_{b} /n$$
(12)

Step 3. Taking x1 and μ1 as the initial value and control parameter of SLCS, the chaotic sequence A1 is obtained by iterating the system mb × nb + 1000 times and discarding the first 1000 values (eliminating transient effects).

Step 4. Chaotic sequence A1 is processed according to Eq. (13) to obtain index sequence Q. Then inter-block index scrambling of image Pb is performed according to index sequence Q to get initial scrambled image P1, as shown in Algorithm 1.

$$\left[ {\sim ,Q} \right] = {\text{sort}}\left( {A_{1} } \right)$$
(13)

Step 5. Take x2 and μ2 as the initial value and control parameter of SLCS, iterate the system Mb × Nb + 1000 times, and discard the first 1000 values (eliminate transient effects) to obtain chaotic sequence A2.

Step 6. The pixel values in each block of P1 are read into the one-dimensional sequence layer by layer, and the scrambled image P2 is obtained by dynamic Josephus scrambling according to the corresponding part Bi of chaotic sequence A2. Bi is calculated according to Eq. (14). The description of dynamic Josephus scrambling is shown in Algorithm 2.

$$B_{i} = A_{2} (m*n*(i - 1) + 1:m*n*i),\;i = 1,\;2,\;3...\;m_{b} *n_{b} .$$
(14)

Step 7. Remove the filled pixels in scrambled image P2 and resize the image to M × N. To further interfere with the pixel position of the image, a global zigzag scrambling is performed on image P2 to obtain the final scrambled image P3. The specific scrambling process is shown in Figs. 7 and 8.

Algorithm 1:
figure a

Inter-block scrambling

Algorithm 2:
figure b

Dynamic Josephus scrambling

Fig. 7
figure 7

Inter-block scrambling

Fig. 8
figure 8

In-block scrambling

3.2.2 Diffusion process

The diffusion operation is adopted to alter the pixel values in the image more effectively, thereby better concealing the plaintext information and enhancing resistance to attacks. The specific diffusion steps are as follows:

Step 1. Take x3 and μ3 as the initial values and control parameters of SLCS, iterate the system M × N + 1000 times, and discard the first 1000 values (eliminate transient effects) to obtain the chaotic sequence A3. Similarly, take x4 and μ4 as the initial values and control parameters of SLCS, iterate the system M × N + 1000 times, and discard the first 1000 values (eliminate transient effects) to obtain chaotic sequence A4.

Step 2. The two one-dimensional chaotic sequences A3 and A4 are transformed into two one-dimensional chaotic integer sequences a3 and a4 by Eqs. (1516).

$$a_{3} = \bmod (floor(A_{3} \times 10^{6} ),\;256)$$
(15)
$$a_{4} = \bmod (floor(A_{4} \times 10^{6} ),\;256)$$
(16)

Step 3. The image P3 is converted into a one-dimensional sequence p. Then, a new one-dimensional sequence c is obtained by changing the size of the pixel values in p according to Eq. (17).

$$c = p \oplus a_{3} \oplus \bmod (a_{4} + floor((A_{3} + A_{4} )*(x_{3} *\mu_{3} + x_{4} *\mu_{4} )*10^{6} ),\;256)$$
(17)

Step 4. The one-dimensional sequence c is adjusted to M × N, the same size as the plaintext image P, and the final ciphertext image C is obtained.

3.3 Decryption process

Image decryption is the inverse process of image encryption. During the decryption process, the key is sent along with the ciphertext image to the decryption party. The specific steps are as follows:

Step 1. As in the encryption process, the initial value and control parameters of SLCS are obtained by processing the known key, and then the chaotic sequences A1, A2, A3 and A4 required by the decryption process are obtained by iterating the system.

Step 2. Perform the inverse diffusion process on ciphertext image C according to the chaotic sequence A3 and A4 to obtain scrambled image P3.

Step 3. Perform a zigzag inverse scrambling on P3 to get P2. For P2, fill pixels with a pixel value size of 300 and adjust the image size to Mb × Nb. P2 is partitioned, and P1 is obtained by dynamic Josephus inverse scrambling according to chaotic sequence A2. Then, the index sequence Q is obtained according to the chaotic sequence A1, and the inverse process of index block scrambling of P1 is carried out according to Q, and Pb is obtained.

Step 4. Finally, remove the pixels filled in Pb and adjust the image size to M × N to get the plaintext image P.

4 Simulation results and security analysis of gray image

In this section, the effectiveness and performance of the image encryption algorithm in this paper are verified by the simulation results and security analysis of gray images. Security analysis includes key space and sensitivity analysis, multiple statistical analysis, differential attack analysis, robustness analysis, etc. In this paper, MATLAB R2023a was used for simulation experiments and deployed on a computer equipped with Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz, 4GB RAM, and Windows 10 operating system.

4.1 Simulation results

The selected grayscale images include Boat, Baboon, Pepper, Black and White, and the size of five images is 512 × 512. The five plaintext images are encrypted and decrypted; the results are shown in Fig. 9.

Fig. 9
figure 9

Simulations results of the encryption and decryption: a Plain images; b Cipher images; c Decrypted images

4.2 Key space analysis

The key space refers to the total number of keys available for use in the algorithm. A larger key space provides greater resistance against brute force attacks, resulting in higher algorithm security. In the algorithm presented in this paper, the SHA-512 hash function is first used to generate the initial key. This function links the initial key to the plaintext image, producing an initial key K of 512 bits. The key space of the initial key K is 2512. Subsequently, the initial key K is used to generate the initial values and control parameters of SLCS, as well as the block size. Therefore, the key space of the algorithm proposed in this paper exceeds 2512, far greater than 2100, meeting the security requirements for key space.

4.3 Key sensitivity analysis

Highly secure image encryption algorithms are highly sensitive to the key. Even slight variations in the key can result in completely different decrypted images compared to those produced with the original key. Encrypting the grayscale image Boat using the original key and then decrypting the ciphertext image using both the correct key and a slightly altered incorrect key yields disparate results. In this algorithm, SLCS involves four initial values, x1, x2, x3, x4, and four control parameters, μ1, μ2, μ3, μ4. Taking x1 and μ1 as examples, two incorrect keys are generated by making minor changes to x1 and μ1. Figure 10a illustrates the result of decrypting the ciphertext image using the correct key, demonstrating that the correct key successfully decrypts the ciphertext image to produce the original image. Figure 10b, c depict the results of decrypting the ciphertext image using incorrect keys, showing that incorrect keys fail to properly decrypt the ciphertext image. Therefore, the algorithm presented in this paper meets the requirement for high sensitivity to the key.

Fig. 10
figure 10

Analysis of key sensitivity using Boat image: a Decrypted image using correct key; b Decrypted image using wrong key, where x1 = x1 + 10−14; c Decrypted image using wrong key, where μ1 = μ1 + 10−14

4.4 Histogram analysis

Histograms provide an intuitive reflection of the distribution of different pixels in an image and are one of the important indicators for measuring the security of encryption algorithms. Typically, the pixel distribution in plaintext images is uneven. To enhance the resistance of encrypted images against statistical analysis attacks, making it difficult for attackers to extract useful information from the pixel value distribution, the pixels in the ciphertext should be distributed as evenly as possible. Therefore, the more uniform the distribution of the ciphertext histogram, the better the security of the encryption algorithm. Taking three selected grayscale images, Boat, Baboon, and Pepper, as examples, the histograms before and after encryption are analyzed. As shown in Fig. 11, it can be observed that the distributions of the plaintext histograms before encryption are uneven, while the distributions of the ciphertext histograms after encryption are relatively uniform. This demonstrates that the algorithm proposed in this paper can effectively resist statistical attacks.

Fig. 11
figure 11

Histogram analysis: a Histogram of Boat’s plain image; b Histogram of Boat’s cipher image; c Histogram of Baboon’s plain image; d Histogram of Baboon’s cipher image; e Histogram of Pepper’s plain image; f Histogram of Pepper’s cipher image

4.5 Correlation analysis

In digital images, pixels do not exist independently; there exists a strong correlation between adjacent pixels. Correlation analysis is a crucial method for evaluating the quality of encryption algorithms, wherein the magnitude of correlation coefficients is one of the key indicators for measuring the algorithm's resistance to attacks. To enhance the resistance of ciphertext images against statistical attacks, it is essential to minimize the correlation between adjacent pixels in the image, aiming to approach a correlation coefficient close to zero. Equations (18)–(21) are used to calculate the correlation between adjacent pixels in the image.

$$r_{xy} = \frac{{{\text{cov}} (x,\;y)}}{{\sqrt {D(x)} \sqrt {D(y)} }}$$
(18)
$${\text{cov}} (x,\;y) = E((x - E(x))(y - E(y)))$$
(19)
$$E(x) = \frac{1}{N}\sum\limits_{i = 1}^{N} {x_{i} }$$
(20)
$$D(x) = \frac{1}{N}\sum\limits_{i = 1}^{N} {(x_{i} } - E(x))^{2}$$
(21)

where x and y are the gray values of two adjacent pixels. E(x), D(x), and cov(x, y) are the expectation, variance, and covariance, respectively.

Taking the selected grayscale images Boat, Baboon, and Pepper as examples, 5000 pairs of adjacent pixels were selected from both the plaintext and ciphertext images to test their correlation in horizontal, vertical, and diagonal directions. Figure 12 illustrates the distribution of adjacent pixels in the horizontal, vertical, and diagonal directions before and after encryption. In the figure, blue, orange, and yellow represent horizontal, vertical, and diagonal distributions, respectively. It can be observed from the figure that the distribution of adjacent pixels in the plaintext images is relatively concentrated in all three directions, whereas the distribution of adjacent pixels in the ciphertext images is more uniform in all three directions. Table 2 provides a more accurate comparison of correlation coefficients for different images and different algorithms. It is evident from the table that the correlation coefficients between adjacent pixels in the plaintext images are close to 1 in all three directions, indicating a very strong correlation. In contrast, the correlation coefficients between adjacent pixels in the ciphertext images are close to 0 in all three directions, indicating a very weak correlation. Furthermore, compared with algorithms from other literature, the algorithm proposed in this paper demonstrates better resistance against statistical attack analysis.

Fig. 12
figure 12

Correlation analysis: a Correlation of Boat’s plain image; b Correlation of Boat’s cipher image; c Correlation of Baboon’s plain image; d Correlation of Baboon’s cipher image; e Correlation of Pepper’s plain image; f Correlation of Pepper’s cipher image

Table 2 Correlation coefficients of images

4.6 x2 test

The x2 test can further analyze whether the distribution of pixel values in the ciphertext image is uniform, and its value is calculated by Eq. (22).

$$\mathop x\nolimits^{2} = \sum\limits_{i = 0}^{255} {\frac{{(v_{i} - v_{0} )^{2} }}{{v_{0} }},\;v_{0} = (M \times N)/256}$$
(22)

where vi and v0 denote the actual and desired frequency of occurrence of pixel value i. The smaller the x2 value, the more uniform the distribution of pixel values. To make the ciphertext image more resistant to statistical attacks, the x2 value should be as small as possible. The significance level α is set to 0.05, \(x_{0.05}^{2}\) = 293.2478. For example, the five selected grayscale images, Boat, Baboon, Pepper, Black, and White, are subjected to the x2 test on their plaintext images and ciphertext images, and the results are shown in Table 3. The table shows that the x2 values of all ciphertext images are less than 293.2478, and all of them pass the x2 test. Therefore, the encryption algorithm proposed in this paper has good resistance to statistical attacks.

Table 3 The results of x2 test

4.7 Information entropy analysis

Information entropy is an important index to measure the degree of confusion of an image, and the more significant the value, the higher the randomness and degree of confusion of an image. Equation (23) is the calculation formula of information entropy.

$$H(e) = \sum\limits_{i = 0}^{{2^{N} - 1}} {p(e_{i} )\log_{2} } \frac{1}{{p(e_{i} )}}$$
(23)

where N is the binary length of the pixel, and p(ei) represents the probability of the occurrence of pixel ei. In theory, when the value of information entropy is close to 8, the encrypted image has a higher degree of confusion and security because eight corresponds to a byte of complete information. To verify the influence of the proposed algorithm on the degree of image chaos, the information entropy of Boat, Baboon, Pepper, Black, and White of five grayscale images before and after encryption is listed in Table 4, and the results are compared with those in related literature. It can be observed from the table that the information entropy of the encrypted image increases significantly and is close to the ideal value of 8. This shows that the proposed algorithm can effectively improve the degree of image confusion. The comparison results with other algorithms show that the proposed algorithm is closer to the ideal value of 8 in terms of information entropy, proving that it has better security.

Table 4 The results of IE test and the comparison with the related algorithms

4.8 Pixel disparity analysis

Peak signal-to-noise ratio (PSNR) and mean square error (MSE) are usually used to test the pixel difference between plaintext images and ciphertext images and can be used as indicators to evaluate image quality. PSNR indicates the degree of image distortion. The smaller the PSNR value, the higher the degree of ciphertext image distortion. PSNR and MSE can be calculated by Eqs. (24) and (25).

$$PSNR = 20 \times \log_{10}\left (\frac{255}{{\sqrt {MSE} }}\right)$$
(24)
$$MSE = \frac{1}{M \times N}\sum\limits_{i = 1}^{M} {\sum\limits_{j = 1}^{N} {(P(i,\;j) - C(i,\;j))^{2} } }$$
(25)

where P(i, j) and C(i, j) are pixel values of plaintext and ciphertext images, respectively. When testing plaintext images and ciphertext images, the smaller the PSNR value and the larger the MSE value, the better the encryption effect of the algorithm. Table 5 lists the MSE and PSNR values of several gray-scale images and compares them with the results in related literature. It can be seen from the data in the table that the PSNR value of the encryption algorithm proposed in this paper is smaller, which proves that the encryption algorithm proposed in this paper has higher security.

Table 5 MSE and PSNR

4.9 Differential attack analysis

Differential attack is a very effective type of security attack. It modifies a pixel value of the plaintext image, encrypts the image, and then compares and analyzes the difference between the ciphertext image and the original ciphertext image to obtain the relevant information of the encryption algorithm. Pixel conversion ratio (NPCR) and uniform mean change intensity (UACI) are two indexes to measure the ability of an algorithm to resist differential attacks. NPCR and UACI can be calculated by Eqs. (26)–(28).

$$NPCR = \frac{{\sum\nolimits_{i,j} {D(i,\;j)} }}{M \times N} \times 100\%$$
(26)
$$UACI = \frac{1}{M \times N}\sum\limits_{i,j} {\frac{{\left| {C_{1} (i,\;j) - C_{2} (i,\;j)} \right|}}{255}} \times 100\%$$
(27)
$$D(i,\;j) = \left\{ \begin{gathered} 1\,,\quad C_{1} (i,\;j) \ne C_{2} (i,\;j)\quad \hfill \\ 0\,,\quad C_{1} (i,\;j) = C_{2} (i,\;j) \hfill \\ \end{gathered} \right.$$
(28)

where C1 and C2 represent the ciphertext image before and after changing a pixel value, respectively, and M and N represent the size of the image.

\(N_{\alpha }^{*}\) and \(U_{\alpha }^{*}\) are the two critical values of NPCR and UACI, respectively. The algorithm passes the test if the NPCR value is more significant than \(N_{\alpha }^{*}\) and the corresponding UACI value is in the interval \((U_{\alpha }^{* - } ,\;U_{\alpha }^{* + } )\). Equations (29)–(30) can calculate these three critical values.

$$N_{\alpha }^{*} = \frac{{D - \Phi^{ - 1} (\alpha )\sqrt {D/MN} }}{D + 1}$$
(29)
$$\left\{ \begin{gathered} U_{\alpha }^{* - } = \frac{D + 2}{{3D + 3}} - \Phi^{ - 1} (\alpha /2)\sqrt {\frac{{(D + 2)(D^{2} + 2D + 3)}}{{18(D + 1)^{2} DMN}}} \hfill \\ U_{\alpha }^{* + } = \frac{D + 2}{{3D + 3}} + \Phi^{ - 1} (\alpha /2)\sqrt {\frac{{(D + 2)(D^{2} + 2D + 3)}}{{18(D + 1)^{2} DMN}}} \hfill \\ \end{gathered} \right.$$
(30)

where \(\Phi^{ - 1} {(}{\text{.)}}\) is the inverse cumulative density function of the standard normal distribution N(0,1), and D represents the maximum supported pixel value.

Twenty-five gray-scale images of different sizes were selected from the USC-SIPI database for testing. The test and comparison results of NPCR and UACI for different images are presented in Tables 6 and 7 at significance level α = 0.05, respectively. The mean values of NPCR and UACI for this paper's algorithm are 99.6123% and 33.4614%, respectively, and all images passed the test. Compared with other algorithms, the standard deviation of this paper's algorithm is smaller. Therefore, the algorithm in this paper can effectively resist differential attacks and has high-security performance.

Table 6 NPCR evaluation
Table 7 UACI evaluation

4.10 Robustness analysis

In the transmission process, ciphertext images are inevitably subject to various interference. Some attacks on ciphertext images can cause data loss, making decrypted images blurry or even unrecognizable. A robust encryption algorithm must be able to minimize the impact of these attacks on decrypted images. The common malicious attacks in the image transmission process mainly include clipping attacks and noise attacks, which this paper uses to test the algorithm's robustness.

Taking the selected grayscale image Boat as an example, different degrees of clipping attack and noise attack were tested, and the results were shown in Figs. 13 and 14. As can be seen from Fig. 13, most of the plaintext information can still be obtained after decryption of images clipped at different positions. As seen in Fig. 14, useful information can still be obtained from the decrypted image after different salt and pepper noise levels are used to disturb the ciphertext image. Table 8 gives the PSNR values and comparison results between decrypted images and plaintext images under different degrees of clipping and noise attacks. It can be seen from the table that the proposed algorithm has better PSNR values. Therefore, the proposed algorithm can resist clipping and noise attacks and has strong robustness.

Fig. 13
figure 13

Clipping attack: a 1/8 degree edge clipping image and decrypted image; b 1/4 degree corner clipping image and decrypted image; c 1/4 degree center clipping image and decrypted image; d 1/2 degree left clipping image and decrypted image

Fig. 14
figure 14

Noise attack: a Noise image and decrypted image with 0.05 salt & pepper; b Noise image and decrypted image with 0.1 salt & pepper; c Noise image and decrypted image with 0.3 salt & pepper; d Noise image and decrypted image with 0.5 salt & pepper

Table 8 PSNR test under different level attack

4.11 Computational complexity analysis

In the process of image encryption, the time complexity of key generation is O(1), the time complexity of the scrambling stage is O(Mb × Nb), and the time complexity of the diffusion stage is O(M × N). M and N are the length and width of the plaintext image, respectively, while Mb and Nb are the length and width of the plaintext image after it is filled with pixels. Therefore, the total time complexity of this algorithm is O(Mb × Nb). Table 9 gives the encryption and decryption times of images of different sizes and compares them with other algorithms. It can be seen from the table that the algorithm in this paper has better time efficiency.

Table 9 Time test results (Unit: s)

5 Simulation results and security analysis of color image

This section extends the encryption algorithm of this paper to color images and presents the simulation experimental results and security analysis of color images.

5.1 Simulation results

Color images consist of three channels: R (red), G (green), and B (blue). When encrypting a color image, each of these channels' grayscale images is encrypted separately. Subsequently, the encrypted versions of the three channels are combined to form the ciphertext image. The decryption process is the reverse of the encryption process. Taking color images Airplane, Baboon, and Pepper with a size of 512 × 512 as examples, the encryption and decryption results are shown in Fig. 15.

Fig. 15
figure 15

Simulations results of the encryption and decryption: a Plain images; b Cipher images; c Decrypted images

5.2 Histogram analysis

Figure 16 illustrates the histograms of the plaintext and ciphertext distributions for the color image Pepper across the R, G, and B channels. It can be observed from the figure that the distributions of the plaintext histograms in the three channels are uneven before encryption, while the distributions of the ciphertext histograms in the three channels are relatively uniform after encryption. Therefore, the proposed algorithm demonstrates effective encryption for color images as well.

Fig. 16
figure 16

Histogram analysis of color image Pepper: a Histogram of plain image of R channel; b Histogram of cipher image of R channel; c Histogram of plain image of G channel; d Histogram of cipher image of G channel; e Histogram of plain image of B channel; f Histogram of cipher image of B channel

5.3 Correlation analysis

Figure 17 presents the distribution of adjacent pixels in the R, G, and B channels of the color image Pepper across horizontal, vertical, and diagonal directions. It can be observed from the figure that the distribution of adjacent pixels in the plaintext images across the three channels is relatively concentrated in all three directions, while the distribution of adjacent pixels in the ciphertext images across the three channels is more uniform in all three directions. Therefore, the proposed algorithm can reduce the correlation between adjacent pixels in different channels, thus enhancing resistance against statistical attack analysis.

Fig. 17
figure 17

Correlation analysis of color image Pepper: a Correlation of plain image of R channel; b Correlation of cipher image of R channel; c Correlation of plain image of G channel; d Correlation of cipher image of G channel; e Correlation of plain image of B channel; f Correlation of cipher image of B channel

5.4 Robustness analysis

Figures 18 and 19 respectively display the results of cropping and noise attack tests on the color image Pepper. It can be seen from the figures that even after being subjected to different degrees of attacks, the proposed algorithm can still decrypt most of the information from the ciphertext image. Therefore, for color images, the proposed algorithm is also capable of resisting cropping and noise attacks.

Fig. 18
figure 18

Clipping attack: a 1/8 degree edge clipping image and decrypted image; b 1/4 degree corner clipping image and decrypted image; c 1/4 degree center clipping image and decrypted image; d 1/2 degree left clipping image and decrypted image

Fig. 19
figure 19

Noise attack: a Noise image and decrypted image with 0.05 salt & pepper; b Noise image and decrypted image with 0.1 salt & pepper; c Noise image and decrypted image with 0.3 salt & pepper; d Noise image and decrypted image with 0.5 salt & pepper

5.5 Other analysis

This section conducted a series of common tests on the ciphertext images of the R, G, and B channels of the color image Pepper, including information entropy, NPCR, UACI, x2, MSE, and PSNR. The experimental results are respectively listed in Tables 10 and 11. Observing the data in the tables, it can be seen that the proposed algorithm performs close to the ideal values in the tests, highlighting the high security of the encrypted color images. The algorithm demonstrates excellent encryption performance for color images.

Table 10 Information entropy, NPCR and UACI for three channels of R, G and B
Table 11 x2, MSE and PSNR for three channels of R, G and B

6 Conclusion

This paper proposes a novel one-dimensional Sine-Logistic chaotic system (SLCS). Through various testing metrics such as bifurcation diagram, sensitivity analysis, Shannon entropy, etc., the superiority of SLCS in randomness, sensitivity to initial values, and unpredictability is verified. Compared with related chaotic systems, SLCS exhibits a larger parameter range and better chaotic behavior, making it suitable for image encryption. Based on the new chaotic system, this paper proposes a secure and efficient image encryption algorithm. Firstly, the image is divided into appropriately sized and equal blocks, and chaos sequences generated by the chaotic system are sorted to create indices for inter-block scrambling. Secondly, based on the chaos sequences generated by the chaotic system, each block is subjected to intra-block scrambling using the dynamic Josephus algorithm. Then, a standard zigzag algorithm is applied to globally scramble the image once, resulting in a semi-encrypted image. Finally, a proposed diffusion formula is used to rapidly diffuse the image, further enhancing the encryption effect, and obtaining the final encrypted image. The initial values and control parameters of SLCS are designed and generated by combining the SHA-512 hash function with the plaintext image. Simulation results on grayscale and color images demonstrate that the proposed algorithm has a large key space, is highly sensitive to the key, and exhibits good encryption performance. Additionally, simulation experiments including statistical attack analysis, entropy analysis, pixel difference analysis, differential attack analysis, robustness analysis, and computational complexity analysis are conducted. Comparative analysis with other algorithms demonstrates that the proposed algorithm can effectively resist common attacks such as statistical attacks and differential attacks, with high security and time efficiency. In future research, we will further improve the chaotic system, increase the number of control parameters, enhance the complexity of key generation, and propose even more secure image encryption algorithms.