View full-text article in PMC Entropy (Basel). 2023 Jul 31;25(8):1147. doi: 10.3390/e25081147 Search in PMC Search in PubMed View in NLM Catalog Add to search Copyright and License information © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/). PMC Copyright notice 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)(i−1,R(t))+˙Q(3)(i−1,R(t))⊗C(2)(i−2,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)(i−1,R(t)); 15:end for Output: The intermediate ciphertext image C(2).