A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Rot13 page! Here, you'll find a description of the project as well as a list of sample programs written in various languages.
This article was written by:
ROT13 is a letter substitution cipher where every letter is replaced by the
letter 13 letters after it alphabetically and wrapping from Z
to A
if necessary:
ABCDEFGHIJKLMNOPQRSTUVWXYZ -> NOPQRSTUVWXYZABCDEFGHIJKLM
As a result, encrypted strings can be decrypted using the same algorithm:
NOPQRSTUVWXYZABCDEFGHIJKLM -> ABCDEFGHIJKLMNOPQRSTUVWXYZ
Write a sample program that takes a string of text as input. It should then encrypt the inputted text using ROT13 and output the result to the console.
$ ./rot13.lang "the quick brown fox jumped over the lazy dog"
gur dhvpx oebja sbk whzcrq bire gur ynml qbt
The solution should handle both lower case and capital letters
$ ./rot13.lang "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG"
GUR DHVPX OEBJA SBK WHZCRQ BIRE GUR YNML QBT
Any characters/symbols besides a-z and A-Z should be ignored.
$ ./rot13.lang "The quick brown fox jumped. Was it over the lazy dog?"
Gur dhvpx oebja sbk whzcrq. Jnf vg bire gur ynml qbt?
In addition, there should be some error handling for situations where the user doesn't supply any input.
Every project in the Sample Programs repo should be tested. In this section, we specify the set of tests specific to Rot13. In order to keep things simple, we split up the testing as follows:
Description | Input | Output |
---|---|---|
Sample Input Lower Case | "the quick brown fox jumped over the lazy dog" | "gur dhvpx oebja sbk whzcrq bire gur ynml qbt" |
Sample Input Upper Case | "THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG" | "GUR DHVPX OEBJA SBK WHZCRQ BIRE GUR YNML QBT" |
Sample Input Punctuation | "The quick brown fox jumped. Was it over the lazy dog?" | "Gur dhvpx oebja sbk whzcrq. Jnf vg bire gur ynml qbt?" |
Description | Input |
---|---|
No Input | |
Empty Input | "" |
All of these tests should output the following:
Usage: please provide a string to encrypt
There are 21 articles: