Przeglądaj źródła

README-en.md edited online with Bitbucket

Jose R Ortiz Ubarri 8 lat temu
rodzic
commit
acfe6dafee
1 zmienionych plików z 3 dodań i 3 usunięć
  1. 3
    3
      README-en.md

+ 3
- 3
README-en.md Wyświetl plik

@@ -69,11 +69,11 @@ Modular addition is essential for implementing ciphering systems in programming.
69 69
 
70 70
 The remainder of dividing two integers can be obtained using the m*modulo* operator: `%`. 
71 71
 
72
-Going back to Example 1, in the word "ARROZ", the letter 'Z' corresponds to the number 25; by hving a displacement of 3 spaces, we add 3 to 25 and that results in 28 which is greater than 25. Id we take the remainder of the divion of $25+3$ by 26, `(25+3) % 26`, we obtain 2, that corresponds to the letter 'C'.
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
+
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'. 
73 75
 
74
-The effect of the circular shift is achieved by using the modulo 26 operation because it converts the result of the addition to an integer in the range [0,25]. For instance, if we were to shift the letter ‘Z’ by three positions, this would be performed by adding ( 25 + 3 ) % 26 which equals 2, whose corresponding letter is ‘C’.  
75 76
 
76
-To convert an uppercase letter to a number in the [0,25] range we can apply our knowledge of the ASCII code. The code for the uppercase letters is in the range [65,90]  (‘A’ is 65, ‘Z’ is 90). Thus, to convert an uppercase case to a number in the range [0,25], a simple subtraction by 65 does the trick (i.e. `’A’ - 65 = 0`, `’Z’ - 65 = 25`).  Observe that to go from the [0,25] range to the ASCII code of its corresponding uppercase character we simply add 65 to the number. For instance, number 3 corresponds to the letter whose ASCII code is $3 + 65 = 68$, i.e. letter ‘D’.  
77 77
 
78 78
 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 79