1 Introduction

With the development of computer techniques, massive amounts of information are being transmitted, stored and shared every day. In recent years, people have paid more and more attention to information security. Many fields produce a large number of images carrying confidential information every day. To ensure the security of image content, the mainstream methods are image encryption and digital steganography. Image encryption uses pixel scrambling and diffusion to turn images into meaningless snowflake images [2,3,4,5,6,7,8, 10,11,12, 14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30], while digital steganography protects image security by hiding images [1, 9, 13]. This article mainly studies image encryption.

In image encryption algorithms, chaotic systems are usually used for encryption due to their unpredictability and sensitivity [2, 3, 5,6,7,8, 10,11,12, 14,15,16,17,18,19,20,21,22,23,24,25,26,27]. Some scholars study the encryption of images in the time domain [2, 4, 7, 16, 17, 19,20,21, 25,26,27]. Guodong Li et al. used 5-D Cellular Neural Networks and Logistics chaos to scramble and diffuse the image [16]. Some scholars study image encryption in the frequency domain [3, 5, 12, 14, 15, 18, 22, 24]. Fourier transform, wavelet transform, Fresnel transform and other transformations are used to transform the image and the encryption is carried out in the frequency domain. Feng et al. proposed the encryption algorithm based on adaptive wavelet chaos, which used the convex optimization-particle swarm optimisation algorithm to enhance the adaptive ability of wavelet transform and scramble low-frequency coefficients. This algorithm has a stronger ability to resist attacks, but the decrypted image is a little distorted [3]. Guodong Li et al. used fractional Fourier transform to transform the image to the frequency domain, and used double chaos systems to scramble and diffuse pixels in the frequency domain [15]. Shakir H. R et al. proposed an encryption algorithm based on selective AES and wavelet transform. First, the plaintext image was decomposed by wavelet, and then the low-frequency coefficients were encrypted by the AES algorithm. After the image was reconstructed, the image was scrambled by chaos [22]. However, the encryption algorithms only aim at a single image, which is low efficient when encrypting multiple images.

With the increase of image data, the traditional single-image encryption algorithm has the problem of low efficiency in practice. Multi-image encryption has attracted the attention of scholars [11, 12, 17, 20, 21, 24, 25]. Sahasrabuddh A et al. proposed a multi-image encryption algorithm based on 3D scrambling and hyperchaotic systems, which let multiple ordinary images generate a 3D image, and use chaos theory and the concept of elliptic curve Elgamar cryptographic system to generate cryptographic images and shared keys. This algorithm has ideal cryptographic statistics and is highly efficient [21]. Lei Zhang et al. proposed a multi-image encryption algorithm based on bit plane. The algorithm decomposed k images into 8 k bit plane, scrambled the high pixel bit and performed XOR on the low pixel bit [25]. K. Patro et al. proposed an algorithm for multiple grey image encryption using cross-coupled chaotic mapping. This algorithm uses the cross-coupled chaotic sequence to improve the security level and has high efficiency [20]. Some scholars have studied multi-image encryption in the frequency domain. Chun-Lai Li proposed a robust chaotic mapping multi-image encryption algorithm in the wavelet domain. Multiple ciphertexts are pieced together into an image, then the image is decomposed by the discrete wavelet. The low-frequency coefficients are scrambled by cat mapping, and the image is reconstructed. The algorithm has a certain degree of anti-attack ability, but the article does not test the efficiency of the algorithm [17]. However, the existing multi-image encryption algorithms rarely transform 3D images into the frequency domain for encryption.

Inspired by the work of predecessors, for the problems of low efficiency of multi-image encryption algorithm, poor anti-attack, distortion of decrypted images, limited image shape and so on, this paper proposes an efficient multi-image encryption algorithm based on wavelet transform and three-dimensional shuffling scrambling. First, design the dynamic pseudo-random sequence generator based on a dynamic chaotic library with three one-dimension chaotic maps and the roulette algorithm, which is highly associated with the plaintext image. Then, the multiple images are divided into blocks and then reconstructed into an image cube. The wavelet transform is performed on each layer of the image cube and the low-frequency coefficients are scrambled by the 3D shuffle algorithm. Finally, use the scrambled low-frequency coefficients and high-frequency parts to reconstruct the cube. After reconstruction, the chaotic matrix is used to perform the bitwise XOR operation with each layer of the image cube to obtain the final encrypted image. The algorithm has ideal ciphertext statistical characteristics, high running speed, and anti-attack.

Section 2 of this paper will mainly explain the design of the multi-image encryption algorithm based on wavelet transform and how to construct an image cube. Section 3 explains the design of the dynamic pseudo-random sequence generator based on roulette algorithm. Section 4 explains the design of the 3D scrambling algorithm based on the shuffling algorithm. Section 5 gives the specific steps of the encryption algorithm. Section 6 performs simulation experiments, analyzes the proposed image encryption algorithm and compares it with the mainstream encryption algorithms. Finally, the last section summarizes and discusses the full text.

2 Preliminaries

2.1 Haar wavelet transform

Wavelet transform is a transform analysis method, which is developed from Fourier transform. It improves the limitation that Fourier transform cannot change the window size and has no adaptive ability. Therefore, it is favoured by many scholars and is widely used in various fields. After the image is subjected to the two-dimensional discrete wavelet transform, four sub-images are obtained. LL is the low-frequency part that contains the most information of the original image, while HL, LH and HH are detail parts in horizontal, vertical and diagonal directions respectively.

The proposed encryption algorithm uses discrete two-dimensional Haar wavelet transform on the image. As shown in Fig. 1, the 4 × 4 matrix A is decomposed by Haar wavelet. First, the average between the adjacent elements in each row is placed to the left of each row in order. Then, the adjacent elements in each row are differentiated and divided by two and the resulting values are placed on the left side of each row in order. Each row is treated in this way to obtain matrix A1. The red part on the left side of A1 is the low-frequency part L, and the blue part on the right side is the high-frequency detail part H. Perform corresponding calculations on each column of A1 to obtain the wavelet two-level decomposition matrix A2. The red part in the upper left corner of A2 is the low-frequency part LL and the remaining parts are the high-frequency detail parts LH, HL, LL.

Fig. 1
figure 1

Discrete two-dimensional Haar wavelet transform

2.2 Construct image cube

The proposed algorithm requires preprocessing of the image shape. Namely, it reconstitutes multiple images to be encrypted into an image cube. In this step, the images need to be divided into blocks and overlapped. Suppose the images to be encrypted are P1, P2, …, Pn, and the size are m1 × n1, m2 × n2, …, mn × nn respectively. The amount of data is M = (m1 × n1)(m2 × n2)⋯(mn × nn). Set the size of the cube is a × a × b. Calculate a, b such that M ≈ a × a × b. Since the proposed encryption algorithm encrypts the low-frequency coefficients of the image cube, if the image block is too small, it will cause image information loss, so set a, b to make a as large as possible and \( \mid \frac{a}{4}-b\mid \) as small as possible. If a × a × b ≠ M, it can be filled with 0 to construct a cube. The constructed image cube is shown in Fig. 2.

Fig. 2
figure 2

Image cube

3 The design of dynamic pseudo-random sequence generator based on roulette algorithm

This section explains the design of the dynamic pseudo-random sequence generator based on the roulette algorithm and a dynamic chaotic library with three kinds of one-dimension chaotic maps that are highly efficient and have good complexity. And the pseudo-random sequence is highly associated with the plaintext image.

3.1 The design of dynamic chaos library

Chaotic sequences that are used for image encryption are required to have sufficient complexity and ergodicity, and at the same time, computation efficiency must be taken into consideration. Based on these considerations, select three new types of one-dimensional chaos to construct the dynamic chaos library, improved Henon map [26], Hybrid map [6] and L-F cascade map [18].

The optimised Henon mapping has higher complexity and larger parameter space than the traditional Henon mapping, as shown in formula (1).

$$ \Big\{{\displaystyle \begin{array}{c}{x}_{n+1}=1-a\cos {x}_n^6+{y}_n\\ {}{y}_{n+1}=b{x}_n\end{array}} $$
(1)

When a ∈ [0,1.4], b ∈ [0,0.3], the system is in chaos.

Hybrid mapping is a chaotic mapping composed of Logistic mapping, Tent mapping, and Sin mapping. It has good complexity and uniformity. The formula is shown in Eq. (2).

$$ \Big\{{\displaystyle \begin{array}{c}{x}_{n+1}=\left({r}^{11}/4\ast \sin \left(\pi {r}^2/2\right)\left(1-{x}_n\right)\right)\mathit{\operatorname{mod}}1,r{x}_n\left(1-{x}_n\right)\le 1/2\\ {}{x}_{n+1}=\left({r}^{11}/4\ast \sin \right(\pi {r}^2/2\ast \left(1-r{x}_n\left(1-{x}_n\right)\right)\mathit{\operatorname{mod}}1,r{x}_n\left(1-{x}_n\right)>1/2\end{array}} $$
(2)

Where, when r ∈ [1.4,4], the system is in chaos.

L-F cascade chaos overcomes the blank area of traditional Logistic mapping and it makes the distribution of parameters more uniform. The formula is as Eq. (3) follows.

$$ \Big\{{\displaystyle \begin{array}{c}{x}_{n+1}=\mu {x}_n\left(1-{x}_n\right)\\ {}{F}_n=\left({x}_{n-1}{F}_{n-1}+{x}_{n-2}{F}_{n-2}+{x}_{n-3}{F}_{n-3}\right)\mathit{\operatorname{mod}}1\end{array}} $$
(3)

When μ ∈ [1.5,4], the system is in chaos.

It can be observed from Fig. 3 that these three chaotic systems have good ergodicity and randomness.

Fig. 3
figure 3

Chaotic sequence. a Optimize Henon chaotic sequence, b Hybrid mapping sequence, c L-F cascade chaotic sequence

Chaos library is composed of the above three types of chaos. Each chaotic mapping theory generates three chaos systems with different parameters. The initial values of all chaos systems are determined by the hash value of plaintext. There are twelve chaotic systems in total, as shown in formula (4).

$$ \left\{\begin{array}{c}{C}_1:{x}_{n+1}=1-4.7\cos {x}_n^6+{y}_n,{y}_{n+1}=0.3{x}_n\kern22.75em \\ {}{C}_2:{x}_{n+1}=1-4.8\cos {x}_n^6+{y}_n,{y}_{n+1}=0.28{x}_n\kern22.25em \\ {}\begin{array}{c}{C}_3:{x}_{n+1}=1-4.9\cos {x}_n^6+{y}_n,{y}_{n+1}=0.27{x}_n\kern22.25em \\ {}{C}_4:{x}_{n+1}=1-5.0\cos {x}_n^6+{y}_n,{y}_{n+1}=0.26{x}_n\kern22.25em \\ {}\begin{array}{c}{C}_5:\left\{\begin{array}{c}{x}_{n+1}=\left({3.4}^{11}/{4}^{\ast }\ \sin \left(\pi\ {3.4}^2/2\right)\left(1-{x}_n\right)\right)\operatorname{mod}\ {\mathrm{1,3.4}}_{x_n}\left(1-{x}_n\right)\le 1/2\kern8.5em \\ {}{x}_{n+1}=\left({3.4}^{11}/4\ast \sin \left(\pi\ {3.4}^2/2\ast \left(1-{3.4}_{x_n}\left(1-{x}_n\right)\right)\right)\right.\operatorname{mod}\ {\mathrm{1,3.4}}_{x_n}\left(1-{x}_n\right)>\frac{1}{2}\kern2.5em \end{array}\kern1.25em \right.\\ {}{C}_6:\left\{\begin{array}{c}{x}_{n+1}=\left({3.6}^{11}/4\ast \sin \left(\pi\ {3.6}^2/2\right)\left(1-{x}_n\right)\right) \operatorname {mod}\ {\mathrm{1,3.6}}_{x_n}\left(1-{x}_n\right)\le 1/2\kern9.5em \\ {}{x}_{n+1}=\left({3.6}^{11}/4\ast \sin \left(\pi\ {3.6}^2/2\ast \left(1-{3.6}_{x_n}\left(1-{x}_n\right)\right.\right)\right.\operatorname{mod}\ {\mathrm{1,3.6}}_{x_n}\left(1-{x}_n\right)>\frac{1}{2}\kern5.5em \end{array}\right.\\ {}\begin{array}{c}{C}_7:\left\{\begin{array}{c}{x}_{n+1}=\left({3.8}^{11}/4\ast \sin \left(\pi\ {3.8}^2/2\right)\left(1-{x}_n\right)\right) \operatorname {mod}\ {\mathrm{1,3.8}}_{x_n}\left(1-{x}_n\right)\le 1/2\kern9.5em \\ {}{x}_{n+1}=\left({3.8}^{11}/4\ast \sin \left(\pi\ {3.8}^2/2\ast \left(1-{3.8}_{x_n}\left(1-{x}_n\right)\right.\right)\right.\operatorname{mod}\ {\mathrm{1,3.8}}_{x_n}\left(1-{x}_n\right)>\frac{1}{2}\kern5.25em \end{array}\right.\\ {}{C}_8:\left\{\begin{array}{c}{x}_{n+1}=\left({3.9}^{11}/4\ast \sin \left(\pi\ {3.9}^2/2\right)\left(1-{x}_n\right)\right) \operatorname {mod}\ {\mathrm{1,3.9}}_{x_n}\left(1-{x}_n\right)\le \frac{1}{2}\kern10.5em \\ {}{x}_{n+1}=\left({3.9}^{11}/4\ast \sin \left(\pi\ {3.9}^2/2\ast \left(1-{rx}_n\left(1-{x}_n\right)\right.\right)\right. \operatorname {mod}\ 1,3.9{x}_n=\left(1-{x}_n\ \right)>1/2\kern2em \end{array}\right.\\ {}\begin{array}{c}{C}_9:{F}_n=\left({x}_{n-1}{F}_{n-1}+{x}_{n-2}{F}_{n-2}+{x}_{n-3}{F}_{n-3}\right) \operatorname {mod}\ 1,{x}_{n+1}=3.7{x}_n\left(1-{x}_n\right)\kern9.5em \\ {}{C}_{10}:{F}_n=\left({x}_{n-1}{F}_{n-1}+{x}_{n-2}{F}_{n-2}+{x}_{n-3}{F}_{n-3}\right) \operatorname {mod}\ 1,{x}_{n+1}=3.8{x}_n\left(1-{x}_n\ \right)\kern8.75em \\ {}\begin{array}{c}{C}_{11}:{F}_n=\left({x}_{n-1}{F}_{n-1}+{x}_{n-2}{F}_{n-2}+{x}_{n-3}{F}_{n-3}\right) \operatorname {mod}\ 1,{x}_{n+1}=3.9{x}_n\left(1-{x}_n\ \right)\kern8.75em \\ {}{C}_{12}:{F}_n=\left({x}_{n-1}{F}_{n-1}+{x}_{n-2}{F}_{n-2}+{x}_{n-3}{F}_{n-3}\right) \operatorname {mod}\ 1,{x}_{n+1}=3.99{x}_n\left(1-{x}_n\ \right)\kern8em \end{array}\end{array}\end{array}\end{array}\end{array}\end{array}\right. $$
(4)

3.2 Roulette algorithm

Roulette algorithm is an algorithm based on the probability of individual choice. This paper uses the roulette algorithm to select the chaotic system from the chaos library that generates the pseudo-random sequence for encryption. Suppose k chaos systems are selected from n chaos systems (C1, C2, ⋯, Cn). Set their individual fitness as (s1, s2, ⋯, sn). Specific steps are as follows:

  1. Step 1

    Calculate the probabilities of each chaos system: \( {p}_i={s}_i/\sum \limits_{k=1}^n{s}_k,i\in \left[1,n\right]. \)

  2. Step 2

    Calculate the cumulative probabilities of each chaos system: \( {q}_i=\sum \limits_{k=1}^i{p}_k,i\in \left[1,n\right]. \)

  3. Step 3

    Generate a random sequence in the range (r1, r2, ⋯, rk).

  4. Step 4

    Judge the interval of the cumulative probability of the random number r, and output the selected individual Ci. The rules are as formula (5) shows.

$$ \Big\{{\displaystyle \begin{array}{c}i=1,{r}_i<{q}_1\\ {}i=j,{q}_j<{r}_i<{q}_{j+1}\end{array}} $$
(5)

3.3 The design of the dynamic pseudo-random sequence generator based on roulette algorithm

The specific steps are as follows. Suppose the plaintext image is P.

  1. Step 1

    Calculate the hash values of the plaintext image by the SHA-256 algorithm, and get a hexadecimal string of length 64. The two adjacent hexadecimal characters are converted into a decimal number, and a sequence of 32 is obtained, denoted as H.

  2. Step 2

    Calculate the sequence x0 by the first 20 digits of H, H(1 : 20), the specific calculation formula is as formula (6).

$$ {x}_0=\operatorname{mod}\left(H\left(1:20\right)\ast {10}^{-3},1\right). $$
(6)
  1. Step 3

    Calculate the fitness of the individual (s1, s2, ⋯, s12) in the roulette algorithm through the middle 12 digits of the sequence HH(12 : 23).

  2. Step 4

    Suppose n chaotic sequences need to be generated. Calculate n1 = n/32,R = 1/n. The random number (r1, r2, ⋯, rn) used for selection in the roulette algorithm is calculated as formula (7).

$$ {r}_i=\operatorname{mod}\left( sum\left(H\left(\left(i-1\right)\cdot {n}_1:i\cdot {n}_1\right)\right)\cdot \left(i-1\right)R,1\right),i\in \left[1,2,\cdots n\right]. $$
(7)

Where, sum() is the sum function.

  1. Step 5

    Input individual fitness (s1, s2, ⋯, s12) and selection random number (r1, r2, ⋯, rn) to the roulette algorithm and get the chaos systems (C1, C2, ⋯, Cn). Generate n chaotic sequences by n chaotic systems respectively.

4 The design of 3D scrambling algorithm based on shuffling algorithm

4.1 Knuth–Durstenfeld shuffling algorithm

The Knuth–Durstenfeld shuffle algorithm is improved from the Fisher-Yates shuffle algorithm, which uses a random sequence to sort an array. Suppose the array to be sorted is X and the length is n. The specific steps are as follows.

  1. Step 1

    The length of the array X is n. Set k = n;

  2. Step 2

    Generate a random number p from [0,k-1] and exchange the value of subscript p with the value of subscript k in the array X.

  3. Step 3

    Set k = k-1. Repeat steps 2 and 3;

  4. Step 4

    Until all the elements in X are processed, a new array X is obtained.

4.2 The design of 3D shuffling scrambling algorithm based on the Knuth-Durstenfeld shuffling algorithm

The 3D shuffling scrambling algorithm uses the Knuth–Durstenfeld shuffling algorithm to scramble the pixels in the image cube. The specific steps are as follows:

  1. (1)

    The image cube A was cut into a series of one-dimensional vectors according to the cutting method in Fig. 4a. The one-dimensional vectors were arranged into matrices in order. Then chaotic sequence C1 and Knuth-Durstenfeld shuffling algorithm were used to scramble the matrix by column, and the scrambled matrices were then stacked into cube A1 in order.

  2. (2)

    The image cube A1 was cut into a series of one-dimensional vectors according to the cutting method in Fig. 4b. The one-dimensional vectors were arranged into matrices in order. Then chaotic sequence C2 and Knuth-Durstenfeld shuffling algorithm were used to scramble the matrix by column, and the scrambled matrices were then stacked into cube A2 in order.

  3. (3)

    The image cube A2 was cut into a series of one-dimensional vectors according to the cutting method in Fig. 4c. The one-dimensional vectors were arranged into matrices in order. Then chaotic sequence C3 and Knuth-Durstenfeld shuffling algorithm were used to scramble the matrix by row, and the scrambled matrices were then stacked into cube A3 in order.

Fig. 4
figure 4

Image cube cutting method. a cutting method, b cutting method, c cutting method

5 The proposed algorithm

Assume that the image that needs to be encrypted is P1, P2, …, Pn. The encryption step flowchart is shown in Fig. 5. The specific encryption steps are as follows:

  1. Step 1

    Reconstitute the images P1, P2, …, Pn into an image cube Im as subsection 2.2, assuming the size is a × a × b. Record the size of each image as the key.

  2. Step 2

    Calculate the hash value of the image cube Im, and input it into the dynamic pseudo-random sequence generator in subsection 3.3 to produce pseudo-random sequences ×1, ×2, ×3, ×4, whose lengths are (a/4)*b-1, (a/4)* (a/4)-1, (a/4)*b-1 and a × a × b respectively. Record the hash value as the key.

  3. Step 3

    Perform Haar wavelet transform on each layer of the image cube Im to obtain the low-frequency part of the cube LL and other high-frequency detail parts of the cube LH, HL, HH.

  4. Step 4

    Calculate row1, row2, row3 according to algorithm 1.

Fig. 5
figure 5

Encryption step flow

figure c

Let row1, row2, and row3 be the chaotic sequence of the shuffling algorithm in subsection 4.3. After cutting the cube, row/column vectors are arranged in order to form a matrix, and the row/column scrambled calculation is shown in Algorithm 2, supposed the matrix is LL1 and scrambled its column. Perform three rounds of cutting, row or column scrambling, and reconstruction on the low-frequency part of the cube LL to obtain the scrambling cube LL’.

figure d
  1. Step 5

    Perform Haar wavelet two-level reconstruction on each layer of the scrambled cube LL’ and other high-frequency detail cubes LH, HL, HH to obtain a semi-encrypted cube C-Im.

  2. Step 6

    Calculate c by ×4 as shown in formula (8).

$$ c=\operatorname{mod}\left( floor\left( reshape\left(x4,a,a\right)\ast 10\hat{\mkern6mu} 14\right),256\right) $$
(8)

Where, mod is the modulus function. Floor is the round-down function. And reshape is the reconstructed array size function. Convert c into a pseudo-random matrix with a range of [0,255] and a size of a × a.

  1. Step 7

    Perform bitwise XOR operation on each layer of the semi-encrypted cube C-Im and c to obtain the encrypted image En-IM as shown in formula (9).

$$ En- im\left(:,:,i\right)= bitxor\left(C- im\left(:,:,i\right),c\right),i\in \left[1,2,\cdots, b\right]. $$
(9)

6 Experimental simulation and analysis

6.1 Experimental simulation

To verify the effectiveness of the proposed algorithm, six pictures were selected for simulation experiments, including four grayscale images and two colour images as shown in Table 1. The simulation experiment is carried out on the MATLAB R2020 platform. The encryption and decryption results are shown in Figs. 6 and 7. After encrypting six pictures with different sizes, colors and textures, six meaningless snowflake pictures are obtained. The decrypted pictures are indistinguishable from the original image in visual, indicating that the proposed algorithm is effective.

Table 1 Test images
Fig. 6
figure 6

Encryption and decryption image cubes. a Plaintext image cube, b Ciphertext image cube, c Decrypt image cube

Fig. 7
figure 7

Plaintext images, ciphertext images and decrypt images. a Lena, b Barbara, c market, d flamingos, e Baboon, f west, g Ciphertext images, h Decrypt images

6.2 Decrypted image quality analysis

In this paper, peak signal-to-noise ratio (PSNR) and structural similarity (SSIM) are used as indicators to measure the quality of decrypted images. PSNR is a measure of picture distortion. When PSNR is greater than 30, the picture quality is considered acceptable. SSIM measures the similarity of two images. The SSIM closer to 1, the smaller the image distortion. The PSNR and SSIM values of the decrypted image in this paper are shown in Fig. 8. The PSNR values comparison is shown in Table 2. The PSNR values are greater than 31, and the SSIM values are greater than 0.96. Therefore, it can be considered that the decrypted image has less distortion and better quality.

Fig. 8
figure 8

Decrypted image quality indicators. a Decrypted image PSNR value, b Decrypt image SSIM value

Table 2 PSNR comparison

6.3 Statistical analysis

6.3.1 Histogram analysis

The 3D histogram distribution represents the grey level of each position in the image and it is a graphical indicator of statistical properties that reflects the spatial distribution and grey level value of the image. The plaintext histogram is shown in Fig. 9. The ciphertext histogram is shown in Fig. 10. It can be observed that the plaintext histogram has one or several peaks, showing the characteristics of the plaintext. In contrast, the ciphertext image is almost evenly distributed, which well conceals the statistical characteristics of the plaintext.

Fig. 9
figure 9

Plaintext histogram. a Lena histogram, b Barbara histogram, c market histogram, d flamingos histogram, e Baboon histogram, f west histogram

Fig. 10
figure 10

Ciphertext histogram. a Lena ciphertext histogram, b Barbara ciphertext histogram, c market ciphertext histogram, d flamingos ciphertext histogram, e Baboon ciphertext histogram, f west ciphertext histogram

6.3.2 Correlation coefficient analysis of adjacent pixels

The adjacent pixels in the plaintext image have a high correlation, which is one of the important characteristics of the image. An effective encrypted image should generate ciphertext with a low correlation between adjacent pixels. Baboon’s plaintext and ciphertext neighboring pixel relationship diagram is shown in Fig. 11. It can be observed that since the relationship between adjacent pixels of the plaintext is distributed on the diagonal, the similarity of adjacent pixels is very high while the ciphertext image is evenly distributed, and the characteristics of the plaintext cannot be obtained. Table 3 lists the adjacent pixel correlation coefficients of this method and other methods. The correlation coefficients of adjacent pixels of the ciphertext of the proposed algorithm are all close to 0, and the correlation of the ciphertext is very low.

Table 3 Correlation coefficient comparison
Fig. 11
figure 11

Baboon’s plaintext and ciphertext neighboring pixel relationship. a Baboon pixel values of adjacent pixels in the horizontal, vertical, and diagonal directions of the image, b Baboon ciphertext pixel value of adjacent pixels in the horizontal direction, c Baboon ciphertext pixel value of adjacent pixels in the vertical direction, d Baboon ciphertext pixel value of adjacent pixels in the diagonal direction

6.3.3 Complexity test

Time sequence complexity refers to the degree to which the sequence is close to a random sequence. The greater the complexity, the greater the randomness, and the more difficult it is for the sequence to be recovered. The complexity algorithm C0 and spectral entropy (SE) can correctly reflect the complexity characteristics of the system [23]. The larger the C0 and SE values the value, the greater the complexity. The C0 and SE values of the ciphertext in this paper, logistic chaotic sequence and Lorenz chaotic sequence are shown in Table 4. It can be observed that the complexity of the ciphertext is slightly smaller than Logistic sequence, but much larger than the Lorenz system, which has strong complexity.

Table 4 Complexity comparison

6.4 Anti-differential attack analysis

The differential attack is to use the same encryption algorithm to encrypt the plaintext image before and after the change by making small changes to the plaintext image, and to compare the encrypted results for deciphering the algorithm. The number of pixels changes rate (NPCR) is used to evaluate the dependence of the ciphertext image of the algorithm on the plaintext image. The ideal value of NPCR is 99.6045%. Table 5 lists the NPCR values of this method and other methods. It can be seen that this algorithm is closer to the ideal value than other algorithms.

Table 5 NPCR value comparison

6.5 Running speed

Comparing the running time with the proposed algorithm and the recent multi-image encryption algorithm, the experimental data volume, decryption time and encryption time are shown in Table 6. It can be observed that although the algorithm in this paper handles a larger amount of data, it still has a relatively fast speed. Therefore, the proposed algorithm has superiority in running speed.

Table 6 Running speed comparison

6.6 Noise attack and cutting attack

The 3D ciphertext cube image is subjected to a clipping attack and a 10% salt and pepper noise attack before decryption. The 12.5% ciphertext cube is cut as shown in Fig. 12. The decrypted image is shown in Fig. 13. The PSNR values and SSIM values of the decrypted image are shown in Table 7. It can be observed that after cutting 12.5% of the ciphertext cube, there is a certain amount of noise in the decrypted image, but the overall image content is relatively clear. After 10% of the salt and pepper noise attack, the decrypted image is noisy. However, the image content can still be distinguished, so the proposed algorithm has a certain degree of anti-attack.

Fig. 12
figure 12

Cut cube

Fig. 13
figure 13

Decrypted image after the attack. a Decrypt image after cropping attack, b Decrypt image after noise attack

Table 7 Decrypted image PSNR value and SSIM value

7 Conclusion

This paper proposes a multi-image encryption algorithm based on wavelet transform and 3D shuffling scrambling. This paper designs the dynamic pseudo-random sequence generator based on the roulette algorithm and a dynamic chaotic library with three kinds of one-dimension chaotic maps that are highly efficient and have a good complexity, which is highly associated with the plaintext image. To better scramble the image cube, this paper proposes a 3D shuffling scrambling algorithm, which divides the cube into one-dimensional vectors and scrambles the order of the one-dimensional vectors, and then reorganizes the cube. To encrypt multiple images, first, the images to be encrypted are divided into blocks, cut, and then are reconstructed into a 3D cube image. Then, calculate the hash values of the image cube and combine hash value and dynamic chaos library to generate chaos sequences. Perform Haar wavelet transform on each layer of the image cube, and perform 3D shuffling of low-frequency coefficients in three different directions. Reconstruct the cube with the scrambled low-frequency coefficients and high-frequency three parts. Last, the chaotic matrix is XOR with each layer of the image cube to obtain the final encrypted image. The experimental results show that the proposed algorithm is better than other reference methods on the whole. The PSNR values of the decrypted images are all higher than 31 and the SSIM values are all higher than 0.96, so the decrypted image quality is higher. In the histogram analysis, correlation coefficient analysis, complexity analysis and anti-differential attack analysis, the information distribution of the ciphertext is more random, and the ciphertext has good cryptographic statistics. In the running speed test, the algorithm in this paper shows superiority. Under the attack of ciphertext and noise, the decrypted image can still have clear and identifiable content, so the proposed algorithm has a strong anti-attack. The algorithm has no restrictions on the shape of encrypted pictures, which is flexible. In summary, the proposed algorithm is safe, efficient and anti-attack, and has practical application value.