|
@@ -71,9 +71,7 @@ The remainder of dividing two integers can be obtained using the m*modulo* opera
|
71
|
71
|
|
72
|
72
|
Going back to Example 1, in the word "ARROZ", the letter 'Z' corresponds to the number 25; by having a displacement of 3 spaces, we add 3 to 25 and that results in 28 which is greater than 25. If we take the remainder of the divion of $25+3$ by 26, `(25+3) % 26`, we obtain 2, that corresponds to the letter 'C'.
|
73
|
73
|
|
74
|
|
-The process above wors if we can associate the letterfrom 'A' to 'Z' with the number from `0` to `25`. This is achieved using the numeric value of the characters. As in the ASCII code, the value of the letters from 'A' to 'Z' go from 65 to 90, we need to make an adjustment in the calculation so that the `A` is assigned to `0`. To conver an uppercase letter to a number in th renge [0, 25] we only need to substract the number 65 (`'A' - 65 = 0`, `'Z' - 65 = 25`). To change a value from the range [0, 25] to the uppercase letter corresponding to the ASCII code, we only need to add 65 to the number. For example, the number 3 corresponds to the letter that has an ASCII code of $3 + 65 = 68$, the letter 'D'.
|
75
|
|
-
|
76
|
|
-
|
|
74
|
+The process above works if we can associate the letter from 'A' to 'Z' with the number from `0` to `25`. This is achieved using the numeric value of the characters. As in the ASCII code, the value of the letters from 'A' to 'Z' go from 65 to 90, we need to make an adjustment in the calculation so that the `A` is assigned to `0`. To convert an uppercase letter to a number in th renge [0, 25] we only need to substract the number 65 (`'A' - 65 = 0`, `'Z' - 65 = 25`). To change a value from the range [0, 25] to the uppercase letter corresponding to the ASCII code, we only need to add 65 to the number. For example, the number 3 corresponds to the letter that has an ASCII code of $3 + 65 = 68$, the letter 'D'.
|
77
|
75
|
|
78
|
76
|
Figure 3 shows the pseudocode of an algorithm for the Caesar cipher. Each letter ‘c’ in the cleartext message is converted to a number in the range [0,25] (by subtracting ‘A’). The displacement `d` is then added to the number (modulo 26) . Lastly, the result of the modular addition is converted back to its corresponding letter by adding the ASCII code of ‘A’.
|
79
|
77
|
|