ADFGVX was used in World War II, and was invented by Colonel Fritz Nebel. It was first used in March 1918, and is a fractionating transposition cipher which uses a modified Polybius square and a single columnar transposition:
ADFGVX |
Method
First we start with a 6x6 key square and which contains all the letters and numbers:
p h 0 q g 6 4 m e a 1 y l 2 n o f d x k r 3 c v s 5 z w 7 b j 9 u t i 8
We now build a table as with the key square (and is a polybius square):
A D F G V X A | p h 0 q g 6 D | 4 m e a 1 y F | l 2 n o f d G | x k r 3 c v V | s 5 z w 7 b X | j 9 u t i 8
Next we encode the plain text by reading off the two characters in the grid. For example 'foxess' will be FV FG GA DF VA VA.
Next we write the code word under the cipher text:
G E R M A N F V F G G A D F V A V A
Next we do a columnar transposition, and sort the key word alphabetically, and move the columns with this:
A E G M N R G V F G A F V F D A A V
We then read off to get 'GV VF FD GA AA FV' [Try!]
Code
The following is an outline of the code which would implement this:
import sys from pycipher import ADFGVX key='PH0QG64MEA1YL2NOFDXKR3CVS5ZW7BJ9UTI8' keyword='GERMAN' phrase='foxes1' if (len(sys.argv)>1): key=str(sys.argv[1]) if (len(sys.argv)>2): keyword=str(sys.argv[2]) if (len(sys.argv)>3): phrase=str(sys.argv[3]) adfgvx = ADFGVX(key=key, keyword=keyword) res=adfgvx.encipher(phrase) print "Cipher: ",res print "Decipher: ",adfgvx.decipher(res)