Skip to main content
. 2024 Jul 16;26(7):603. doi: 10.3390/e26070603
Algorithm 3 Image-encryption algorithm.
Input: Parameters of the hyperchaotic system {x0,y0,a,b}, plaintext image P, the initial values of the intermediate key Pre and k.
Output: Ciphertext image C and the secret key sequences {X,Y}.
  • 1:

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

  • 2:

    flag=zeros(M,N);                                          ▹ Initialize a zero matrix flag

  • 3:

    X=zeros(1,MN);

  • 4:

    Y=zeros(1,MN);                                   ▹ Initialize the secret key sequences {X,Y}

  • 5:

    for i=1:M do

  • 6:

       for j=1:N do

  • 7:

       Random values {x,y} are obtained iteratively using system (1).

  • 8:

       inext=mod(floor(x106),M)+1;

  • 9:

       jnext=mod(floor(y106),N)+1;

  • 10:

        while flag(inext,jnext)==1 do

  • 11:

        Repeat steps 7 to 9;

  • 12:

        end while

  • 13:

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

  • 14:

        Pre=C(inext,jnext);

  • 15:

        flag(inext,jnext)=1;

  • 16:

        Record {x,y} to sequences {X,Y}, respectively.

  • 17:

       end for

  • 18:

    end for