Jabberwocky!

'Twas brillig, and the slithy toves
  Did gyre and gimble in the wabe;
All mimsy were the borogoves,
  And the mome raths outgrabe.

  --Lewis Carroll

Part 1

Write programs that perform the following mappings on bits/bytes: Here are some sample runs of these transformations:
	$ ./atob wright.txt bit-wright.txt
	$ ./btoa bit-wright.txt ascii-wright.txt
	
and the files: wright.txt, bit-wright.txt, ascii-wright.txt.

Remark: The first and third files should be identical.


Part 2

Also write programs that carry out the following pair of morphisms on bit sequences. This bit-to-bit transformation will be explained in class. Here are some sample runs of these transformations:
	$ ./jabber bit-wright.txt zap-wright.txt
	$ ./wocky zap-wright.txt kapow-wright.txt
	
and the files: bit-wright.txt, zap-wright.txt, kapow-wright.txt.

Remark: The first and third files should be identical (in their bit sequences).


We now combine both pairs of transformations by composing "atob" and "jabber" on one side, and "wocky" and "btoa" on the other side. Since "atob" and "btoa" are inverses of each other, and "jabber" is the inverse of "wocky", we should get the do-nothing (identity) transformation.

Sample file

Here is T.S. Eliot's "Hollow Men".

Some testing the program on the above poem.

    $ ./atob hollow.txt bit-hollow.txt
    $ ./jabber bit-hollow.txt zap-hollow.txt
    $ ./wocky zap-hollow.txt kapow-hollow.txt
    $ ./btoa kapow-hollow.txt out.txt
    $ diff hollow.txt out.txt
	
Here are some output files: bit-hollow.txt, zap-hollow.txt, kapow-hollow.txt, and out.txt.