Research Article
Image Encryption Using the Chaotic Josephus Matrix
Algorithm 1
The generation of a Josephus permutation sequence.
| Input: , the initial total number of persons in a circle | | , the starting position in the circle | | , the counting period | | Output: , the Josephus permutation sequence according to parameter set | | count = 0; done = 0; pos = ; label = zeros(1, ); ; % initial settings | | while (done) % main loop | | todo = label(pos); | | if (todo == 0) % if this person has not been taken out | | count = count + 1; | | if (count == ) % if this is the th person | | (end + 1) = pos; count = 0; label(pos) = 1; | | if (length() == ) | | done = 1; | | end | | end | | end | | pos = pos + 1; | | if (pos > ) | | pos = 1; | | end | | end |
|