Research Article

A Novel Chaotic Image Encryption Algorithm Based on Latin Square and Random Shift

Algorithm 1

Latin square produces L = Latin (Q1, Q2).
Input: Q1 and Q2 are two sequences of equal length
 Output: Latin matrix with order equal to the length of the input sequence
[∼, Qseed] = Sort (Q1);
[∼, Qshift] = Sort (Q2);
for i = 0 : 1: length (Qshift)-1
   L = Rowshift (Qseed, Qshift (i))
end
where Sort (x) is a sorting function, which can sort the sequence x in ascending order and return the sorted sequence and its position index sequence in the original sequence. Qseed and Qshift are the position index sequences obtained after sorting the sequences Q1 and Q2, length (x) represents the length of the sequence x, and Rowshift (x, y) means to move the sequence Qseed loop to the left by y positions.