Description (from Rosetta Code)
The Chaocipher was invented by J.F.Byrne in 1918 and, although simple by modern cryptographic standards, does not appear to have been broken until the algorithm was finally disclosed by his family in 2010.
The task is to code the algorithm in your language and to test that it works with the plaintext 'WELLDONEISBETTERTHANWELLSAID' used in the paper itself.
The following program can be used to either encryt or decrypt text.
To encrypt text (encrypt flag set to true):
To decrypt text (encrypt flag set to false):