A while ago, I spent time playing with modern field/pen & paper ciphers, especially with [Card-Chameleon](http://etd.uwaterloo.ca/etd/memckagu2005.pdf). Card-Chameleon needs two separate full alphabet permutations as a key. As it's a field/pen & paper cipher, I tried to find a computer-less, math-less, way to generate these permutations from passwords. My solution is a two steps process. Let's assume the current password is `PASSWORD` # Step 1 ## 1. Create a base permutation Write down the letters of the password without repetition `P A S W O R D` Fill in the matrix with the remaining letters, leaving space for letters already present in the password P A S W O R D B C E F G H I J K L M N Q T U V X Y Z Read the matrix column by column to get the base permutation base permutation : `P H V A B I S C J Q X W K Y O E L Z R F M T D G N U` It looks nice but related passwords (eg. `PASSWORD`, `PASWWORD`, `PASSWORDS`, `PASSWORDA`, `PAASSWORD`, ...) will produce the very same base permutation. So I needed to do something more to the base permuation, something which takes into account the whole password # Step 2 ## 2. Create a sequence of values based on the whole password Assign to each letter a value equal to its rank in the alphabet A B C D E F G ... Y Z 1 2 3 4 5 6 7 ... 25 26 Convert this rank to base 3, using 3 digits for each letter A B C D E F G ... Y Z 000 001 002 010 011 012 020 ... 220 221 Write down the base 3 digits corresponding to the password P A S S W O R D 120 000 200 200 211 112 122 010 Group them by 2 instead of 3 (if the password has an odd number of letters, append 0 to the base 3 digits of the last character of the passord to be able to make pairs) 12 00 00 20 02 00 21 11 12 12 20 10 Convert the resulting pairs back to base 10 5 0 0 6 2 0 7 4 5 5 6 3 Add 1 to each value 6 1 1 7 3 1 8 5 6 6 7 4 resulting sequence: `6 1 1 7 3 1 8 5 6 6 7 4` ## 3. Now, taking adavange of having a card deck handy, mix up the letters of the base permutation using the resulting sequence created above. Order the cards of the deck in the order of the base permutation, face up. `P H V A B I S C J Q X W K Y O E L Z R F M T D G N U` For each value of the resulting sequence of previous point, deal that many cards, face up, one at a time, to make a pile in reverse order (You may create the pile on the table or better, in your other hand. The only important thing is that the cards must be face up and be in reverse order). Then, put the resulting pile under the card deck. Repeat until the sequence is exhausted. ### *first round* pile: `I B A V H P` remainder of the deck: `S C J Q X W K Y O E L Z R F M T D G N U` new deck: `S C J Q X W K Y O E L Z R F M T D G N U I B A V H P` # Experimental results The final permutations for the related passwords quoted in step 1 are: PASSWORD V A B W K Y O C S E L Z J Q X T D G N U I R H P F M PASWWORD C S P Z J Q X W K F M T D E L U I B A V H R O Y G N PASSWORDS S E L Z J Q X T D G N U I R H P F M O Y K W B A V C PASSWORDA B W K Y O C S E L Z J Q X T D G N U I R H P F M V A PAASSWORD G S P H V A R F K Q X W J C B M T D Y O E L Z U I N