Pārlūkot izejas kodu

README-en.md edited online with Bitbucket

Jose R Ortiz Ubarri 8 gadus atpakaļ
vecāks
revīzija
4bd92fea75
1 mainītis faili ar 7 papildinājumiem un 1 dzēšanām
  1. 7
    1
      README-en.md

+ 7
- 1
README-en.md Parādīt failu

@@ -65,7 +65,13 @@ The Caesar Cypher is a substitution encryption technique that is said to have be
65 65
 
66 66
 ###Using the modulo operator
67 67
 
68
-Modular addition is essential for implementing ciphering systems in programming. In the Ceaser Cypher application above we could htink that every letter of the (English) alphabet is assigned a number between 0 and 25 (‘A’ is 0, ‘B’ is 1, .., ‘Z’ is 25). The Caesar Cypher transforms every letter we convert to its corresponding number in the range [0,25], then add the displacement. To do the cyclic displacement, every time our displacement gives us a letter that corresponds to a number gretaer than 25, we take the remainder of the numer divided by 26 and use the letter that corresponds to the remainder. 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’.  
68
+Modular addition is essential for implementing ciphering systems in programming. In the Ceaser Cypher application above we could htink that every letter of the (English) alphabet is assigned a number between 0 and 25 (‘A’ is 0, ‘B’ is 1, .., ‘Z’ is 25). The Caesar Cypher transforms every letter we convert to its corresponding number in the range [0,25], then add the displacement. To do the cyclic displacement, every time our displacement gives us a letter that corresponds to a number gretaer than 25, we take the remainder of the numer divided by 26 and use the letter that corresponds to the remainder. Note that taking the remainder by dividing the number by 26 gives us results that will be between 0 and 25, which are the values associated with the alphabet. 
69
+
70
+The remainder of dividing two integers can be obtained using the m*modulo* operator: `%`. 
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'.
73
+
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’.  
69 75
 
70 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’.  
71 77