Project: Caesar Cipher
The [[Caesar Cipher]] is one of the oldest and simplest encryption techniques known. Write a filter program that encrypts or decrypts text using a Caesar Cipher. It should only shift alphabetic characters taking into account that uppercase characters should shift to other uppercase characters and lowercase characters should shift to other lowercase characters.
The program should accept two command line arguments. The first is the shift amount (0-25) and the second is the encrypt/decrypt mode. If the second argument is "e", the program should take in clear (unencrypted) text on the standard input and write cipher (encrypted) text on the standard output. If the second argument is "d", the program should take in cipher (encrypted) text on the standard input and write clear (unencrypted) text on the standard output.
Output
$ javac -Xlint CaesarCipher1.java
$ java -ea CaesarCipher1 5 e < ../../data/text/GettysburgAddress.txt
Qnshtqs'x Ljyydxgzwl Fiiwjxx, lnajs Stajrgjw 19, 1863
ts ymj gfyyqjknjqi sjfw Ljyydxgzwl, Ujssxdqafsnf, ZXF
Ktzw xhtwj fsi xjajs djfwx flt tzw kfymjwx gwtzlmy ktwym ts ymnx htsynsjsy, f sjb sfynts, htshjnaji ns Qngjwyd, fsi ijinhfyji yt ymj uwtutxnynts ymfy fqq rjs fwj hwjfyji jvzfq.
Stb bj fwj jslflji ns f lwjfy hnanq bfw, yjxynsl bmjymjw ymfy sfynts, tw fsd sfynts xt htshjnaji fsi xt ijinhfyji, hfs qtsl jsizwj. Bj fwj rjy ts f lwjfy gfyyqj-knjqi tk ymfy bfw. Bj mfaj htrj yt ijinhfyj f utwynts tk ymfy knjqi, fx f knsfq wjxynsl uqfhj ktw ymtxj bmt mjwj lfaj ymjnw qnajx ymfy ymfy sfynts rnlmy qnaj. Ny nx fqytljymjw knyynsl fsi uwtujw ymfy bj xmtzqi it ymnx.
Gzy, ns f qfwljw xjsxj, bj hfs sty ijinhfyj-bj hfs sty htsxjhwfyj-bj hfs sty mfqqtb-ymnx lwtzsi. Ymj gwfaj rjs, qnansl fsi ijfi, bmt xywzllqji mjwj, mfaj htsxjhwfyji ny, kfw fgtaj tzw uttw utbjw yt fii tw ijywfhy. Ymj btwqi bnqq qnyyqj styj, stw qtsl wjrjrgjw bmfy bj xfd mjwj, gzy ny hfs sjajw ktwljy bmfy ymjd ini mjwj. Ny nx ktw zx ymj qnansl, wfymjw, yt gj ijinhfyji mjwj yt ymj zsknsnxmji btwp bmnhm ymjd bmt ktzlmy mjwj mfaj ymzx kfw xt stgqd fiafshji. Ny nx wfymjw ktw zx yt gj mjwj ijinhfyji yt ymj lwjfy yfxp wjrfnsnsl gjktwj zx-ymfy kwtr ymjxj mtstwji ijfi bj yfpj nshwjfxji ijatynts yt ymfy hfzxj ktw bmnhm ymjd lfaj ymj qfxy kzqq rjfxzwj tk ijatynts-ymfy bj mjwj mnlmqd wjxtqaj ymfy ymjxj ijfi xmfqq sty mfaj inji ns afns-ymfy ymnx sfynts, zsijw Lti, xmfqq mfaj f sjb gnwym tk kwjjitr-fsi ymfy ltajwsrjsy tk ymj ujtuqj, gd ymj ujtuqj, ktw ymj ujtuqj, xmfqq sty ujwnxm kwtr ymj jfwym.
Solution