Skip to main content
. 2023 Jul 31;25(8):1147. doi: 10.3390/e25081147
Algorithm 2 Dynamic binary diffusion algorithm
  • Input: 

    The input image C(1), v(x) and U(x) obtained in hash value stacking, and the key streams Q(3).

  •   1:

    Get the height M and width N of C(1);

  •   2:

    Reshape Q(3) into a matrix of size M×N;

  •   3:

    Set r(p)=((v(x)+Q(3)(1,1))modN/8)+N/2;

  •   4:

    Set R(t)=1:r(p);

  •   5:

    Set C(2)NM×N;

  •   6:

    C(2)(1,R(t))=C(1)(1,R(t))+˙Q(3)(1,R(t))U(x)(1,R(t))+˙Q(3)(M,R(t))U(x)(2,R(t));

  •   7:

    C(2)(2,R(t))=C(1)(2,R(t))+˙Q(3)(2,R(t))C(2)(1,R(t))+˙Q(3)(1,R(t))U(x)(3,R(t));

  •   8:

    for  i=3 to M do

  •   9:

         C(2)(i,R(t))=C(1)(i,R(t))+˙Q(3)(i,R(t))C(2)(i1,R(t))+˙Q(3)(i1,R(t))C(2)(i2,R(t));

  •  10:

    end for

  •  11:

    R(t)=(r(p)+1):N;

  •  12:

    C(2)(1,R(t))=C(1)(1,R(t))Q(3)(1,R(t))C(1)(M,R(t));

  •  13:

    for  i=2 to M do

  •  14:

       C(2)(i,R(t))=C(1)(i,R(t))Q(3)(i,R(t))C(2)(i1,R(t));

  •  15:

    end for

  • Output: 

    The intermediate ciphertext image C(2).