Caesar Cipher
One of the early encryption techniques is the Caesar cipher, named after the famous Roman emporer who used it.
While it provides no cryptographic security against modern decryption techniques, it is easy to implement and provides a nice historical way to introduce to this very important field of study.
Input
The first line of the input will be an integer (from 0 to 25), which will be the key. The rest of the input will be lines that contain the message to encrypt. Each of the remaining lines will contain less than 80 characters. Your program should stop when a line contains the only the word STOP.
Output
The output should be a series of encrypted lines, with all upper and lower case letters shifted by the number given in the key places to the right, with z wrapping around to a. Characters that are not upper or lower case letters should be left unchanged.
Example
Example input could contain:
1 The quick brown fox jumped over the lazy dogs numbers and other things 1, 2, and 3! STOP
Given this input above, the program would print out:
Uif rvjdl cspxo gpy kvnqfe pwfs uif mbaz epht ovncfst boe puifs uijoht 1, 2, boe 3!
Test Data
-
The file sample.txt should produce the following output:
gur dhvpx oebja sbk whzcrq bire gur ynml qbtf GUR DHVPX OEBJA SBK WHZCRQ BIRE GUR YNML QBTF fghss yrff guna N !"#$%&'()*+,-./ fghss terngre gura N ohg yrff guna n [\]^_` fghss nsgre m {|}~ fgbc guvf yvar vf abg gur raq FGBC guvf yvar vf abg gur raq rvgure
-
The file sample2.txt should produce the following output:
nby kocwe vliqh zir dogjyx ipyl nby futs xiam NBY KOCWE VLIQH ZIR DOGJYX IPYL NBY FUTS XIAM mnozz fymm nbuh U !"#$%&'()*+,-./ mnozz alyunyl nbyh U von fymm nbuh u [\]^_` mnozz uznyl t {|}~ mnij nbcm fchy cm hin nby yhx MNIJ nbcm fchy cm hin nby yhx ycnbyl