Skip to main content
. 2024 Jul 16;26(7):603. doi: 10.3390/e26070603
Algorithm 4 Image-decryption algorithm.
Input: Ciphertext image C, the secret key sequences {X,Y}, the initial values of the intermediate key Pre and k.
Output: Plaintext image P.
  • 1:

    [M,N]=size(P);                                 ▹ Get image size

  • 2:

    num=1;                        ▹ Position number of the secret key sequence

  • 3:

    for i=1:M do

  • 4:

       for j=1:N do

  • 5:

         inext=mod(floor(X(num)106),M)+1;

  • 6:

         jnext=mod(floor(Y(num)106),N)+1;

  • 7:

         P(i,j)=mod(bitxor(C(inext,jnext),Pre)k,256);

  • 8:

         Pre=C(inext,jnext);

  • 9:

         num=num+1;

  • 10:

       end for

  • 11:

    end for