|
@@ -3,7 +3,7 @@ a simple set of crypt problems.
|
3
|
3
|
|
4
|
4
|
Create a few ciphers. Use String inside of your classes.
|
5
|
5
|
|
6
|
|
-* ROT13 - take the 26 letters of the alphabet and create a `String <- doRot13(String)` method in the ROT13 class
|
|
6
|
+* ROT13 - take the 26 letters of the alphabet and create a `String <- crypt(String)` method in the ROT13 class
|
7
|
7
|
* Caesar - make a subclass of ROT13 that implements the famous caesar cipher.
|
8
|
8
|
* Create you own cipher, using a different set of
|
9
|
9
|
|
|
@@ -17,7 +17,13 @@ ROT13 is used in online forums as a means of hiding spoilers, punchlines, puzzle
|
17
|
17
|
|
18
|
18
|
Applying ROT13 to a piece of text merely requires examining its alphabetic characters and replacing each one by the letter 13 places further along in the alphabet, wrapping back to the beginning if necessary.[3] A becomes N, B becomes O, and so on up to M, which becomes Z, then the sequence continues at the beginning of the alphabet: N becomes A, O becomes B, and so on to Z, which becomes M. Only those letters which occur in the English alphabet are affected; numbers, symbols, whitespace, and all other characters are left unchanged. Because there are 26 letters in the English alphabet and 26 = 2 × 13, the ROT13 function is its own inverse:[3]
|
19
|
19
|
|
20
|
|
-{\displaystyle {\mbox{ROT}}_{13}({\mbox{ROT}}_{13}(x))=x} {\mbox{ROT}}_{13}({\mbox{ROT}}_{13}(x))=x for any basic Latin-alphabet text x.
|
|
20
|
+```Java
|
|
21
|
+String s = "we hold these truths to be self evident"
|
|
22
|
+
|
|
23
|
+if (crypt(crypt(s)) == s) {
|
|
24
|
+ return true;
|
|
25
|
+}
|
|
26
|
+```
|
21
|
27
|
In other words, two successive applications of ROT13 restore the original text (in mathematics, this is sometimes called an involution; in cryptography, a reciprocal cipher).
|
22
|
28
|
|
23
|
29
|
The transformation can be done using a lookup table, such as the following:
|