Переглянути джерело

README-en.md edited online with Bitbucket

Jose R Ortiz Ubarri 8 роки тому
джерело
коміт
6895e32c4a
1 змінених файлів з 22 додано та 22 видалено
  1. 22
    22
      README-en.md

+ 22
- 22
README-en.md Переглянути файл

@@ -1,5 +1,5 @@
1 1
 
2
-# Repetition Structures - Vigenere Cipher
2
+# Repetition Structures - Vigenere Cypher
3 3
 
4 4
 ![](http://demo05.cloudimage.io/s/resize/215/i.imgur.com/DYSdjlN.png)
5 5
 ![](http://demo05.cloudimage.io/s/resize/215/i.imgur.com/TEk9bMp.png)
@@ -11,7 +11,7 @@ One of the advantages of using computer programs is that we can easily implement
11 11
 
12 12
 ##Objectives:
13 13
 
14
-1. Apply repetition structures to cipher a plain-text message.
14
+1. Apply repetition structures to cypher a plain-text message.
15 15
 2. Practice character arithmetic.
16 16
 
17 17
 
@@ -37,13 +37,13 @@ Before coming to the lab session you should have:
37 37
 
38 38
 ---
39 39
 
40
-##Criptography
40
+##Cryptography
41 41
 
42 42
 *Cryptography* is the area of knowledge that studies the theory and methods that are used for protecting information so that non-authorized persons cannot understand it. A *cryptographic system* is a system that transforms a *clear text message* (a message that is understandable to humans) to a *cyphered* text (text that is unintelligible to unauthorized persons).  Authorized persons can *decypher* the *cyphered* text to obtain the original cleartext.
43 43
 
44
-###The Ceasar Cypher
44
+###The Caesar Cypher
45 45
 
46
-The Caesar Cypher is a substitution encryption technique that is said to have been used by Julius Caesar (100 BC - 44 BC), the Roman political and military leader, to communicate with his generals. To encrypt a message using the Caesar Cipher each letter of the clear text message is substituted by the letter found a given number of positions ahead in the alphabet. You may think of this as a shift of the letter in the alphabet. Figure 1 illustrates a shift of 3 spaces within the alphabet. For instance, letter ‘B’ would be substituted by letter ‘E’.
46
+The Caesar Cypher is a substitution encryption technique that is said to have been used by Julius Caesar (100 BC - 44 BC), the Roman political and military leader, to communicate with his generals. To encrypt a message using the Caesar Cypher each letter of the clear text message is substituted by the letter found a given number of positions ahead in the alphabet. You may think of this as a shift of the letter in the alphabet. Figure 1 illustrates a shift of 3 spaces within the alphabet. For instance, letter ‘B’ would be substituted by letter ‘E’.
47 47
 
48 48
 ---
49 49
 
@@ -59,21 +59,21 @@ The Caesar Cypher is a substitution encryption technique that is said to have be
59 59
 
60 60
 ![figure2.png](images/figure2.png)
61 61
 
62
-**Figure 2.** A Caesar cipher disk showing a shift of 8 positions.
62
+**Figure 2.** A Caesar cypher disk showing a shift of 8 positions.
63 63
 
64 64
 ---
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. 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. 
68
+Modular addition is essential for implementing ciphering systems in programming. In the Caesar Cypher application above we could think 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 greater than 25, we take the remainder of the number 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 69
 
70
-The remainder of dividing two integers can be obtained using the m*modulo* operator: `%`. 
70
+The remainder of dividing two integers can be obtained using the *modulo* operator: `%`. 
71 71
 
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'.
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 division of $25+3$ by 26, `(25+3) % 26`, we obtain 2, that corresponds to the letter 'C'.
73 73
 
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'. 
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 the range [0, 25] we only need to subtract 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 75
 
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’. 
76
+Figure 3 shows the pseudocode of an algorithm for the Caesar cypher. 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’. 
77 77
 
78 78
 ---
79 79
 
@@ -90,15 +90,15 @@ Figure 3 shows the pseudocode of an algorithm for the Caesar cipher. Each letter
90 90
     3. return cypheredText 
91 91
 ```
92 92
 
93
-**Figure 3.** Pseudocode for a Caesar cipher algorithm.
93
+**Figure 3.** Pseudocode for a Caesar cypher algorithm.
94 94
 
95 95
 ---
96 96
 
97
-The Caesar cipher is considered a weak encryption mechanism because it can easily be deciphered by using frequency analysis on the ciphered message. For example, we can use the fact that letter ‘e’ is the most frequent letter in most texts. If we find the most frequent letter in a ciphered text it probably corresponds to the letter that was substituted by ‘e’. With this information, we can compute the displacement that was used and decipher the rest of the message.
97
+The Caesar cypher is considered a weak encryption mechanism because it can easily be deciphered by using frequency analysis on the ciphered message. For example, we can use the fact that letter ‘e’ is the most frequent letter in most texts. If we find the most frequent letter in a ciphered text it probably corresponds to the letter that was substituted by ‘e’. With this information, we can compute the displacement that was used and decipher the rest of the message.
98 98
 
99 99
 ###The Vigenere Cypher 
100 100
 
101
-A main weakness of the Caesar cipher is that every letter in the clear text message is shifted by the same number of positions. The Vigenere cipher is a somewhat stronger encryption method because the shift used on each letter is not constant. Whereas the Caesar cipher receives as an input a clear text message and a displacement, the Vigenere receives the clear text message and **keyword**. For now, let's assume that the keyword and the clear text message have the same length. The Vigenere cipher uses the keyword to determine the shift that will be applied to each letter of the cleartext message, i.e. the first letter of the keyword determines the shift number for the first letter of the message and so forth. 
101
+A main weakness of the Caesar cypher is that every letter in the clear text message is shifted by the same number of positions. The Vigenere cypher is a somewhat stronger encryption method because the shift used on each letter is not constant. Whereas the Caesar cypher receives as an input a clear text message and a displacement, the Vigenere receives the clear text message and **keyword**. For now, let's assume that the keyword and the clear text message have the same length. The Vigenere cypher uses the keyword to determine the shift that will be applied to each letter of the cleartext message, i.e. the first letter of the keyword determines the shift number for the first letter of the message and so forth. 
102 102
 
103 103
 **Example 2.** Suppose that the cleartext is “PET” and the keyword is “BED”. Each letter in the **keyword** determines the shift amount of the corresponding letter in the cleartext: letter ‘A’ specifies a shift of 0, ‘B’ is a shift of 1, and so on.  Thus, the ‘B’ in the keyword “BED” states that we shall shift the first letter of the cleartext by 1, the ‘E’ states that we will shift second the letter by 4 and the ‘D’ states that we will shift the last letter by 3.
104 104
 
@@ -120,11 +120,11 @@ Figure 5 shows a table that can be used to determine the Vigenere-ciphered lette
120 120
 
121 121
 ![figure6.png](images/figure6.png)
122 122
 
123
-**Figure 5.** Table for the Vigenere-cipher. The shaded row and column illustrate how to cipher the letter ‘R’ with key letter ‘M’.
123
+**Figure 5.** Table for the Vigenere-cypher. The shaded row and column illustrate how to cypher the letter ‘R’ with key letter ‘M’.
124 124
 
125 125
 ---
126 126
 
127
-If the keyword is shorter than the clear text, the Vigenere cipher simply repeats the keyword as many times as needed to account for all the letters of the clear text. Figure 6, illustrates the keyword and cleartext pairing for an example. 
127
+If the keyword is shorter than the clear text, the Vigenere cypher simply repeats the keyword as many times as needed to account for all the letters of the clear text. Figure 6, illustrates the keyword and cleartext pairing for an example. 
128 128
 
129 129
 ---
130 130
 
@@ -134,7 +134,7 @@ If the keyword is shorter than the clear text, the Vigenere cipher simply repeat
134 134
 | ciphered text   | H | Y | C | X | K | S | T |   | K | A | A | Z |
135 135
 
136 136
 
137
-**Figure 6.** Alignment of a cleartext with a shorter keyword and the resulting cipher.
137
+**Figure 6.** Alignment of a cleartext with a shorter keyword and the resulting cypher.
138 138
 
139 139
 ---
140 140
 
@@ -175,11 +175,11 @@ We will also use the following functions:
175 175
 
176 176
 ## Laboratory session:
177 177
 
178
-You will be completing an application to cipher a message using the Vigenere technique. To simplify coding, the keyword and clear text must consist exclusively of letters. Furthermore, your program must change both the cleartext and keyword to uppercase before ciphering. 
178
+You will be completing an application to cypher a message using the Vigenere technique. To simplify coding, the keyword and clear text must consist exclusively of letters. Furthermore, your program must change both the cleartext and keyword to uppercase before ciphering. 
179 179
 
180 180
 ### Exercise 1 - Keyword and Cleartext of the Same Length
181 181
 
182
-In this exercise, you will implement a function that given a cleartext and keyword of equal length returns the cipher message. 
182
+In this exercise, you will implement a function that given a cleartext and keyword of equal length returns the cypher message. 
183 183
 
184 184
 #### Instructions
185 185
 
@@ -197,11 +197,11 @@ In this exercise, you will implement a function that given a cleartext and keywo
197 197
 
198 198
 ### Exercise 2 - Keyword and Cleartext of Arbitrary Lengths
199 199
 
200
-In this exercise, you will modify the code for the cypher function from Exercise 1 so that the application can now cipher a message using a keyword of arbitrary length. 
200
+In this exercise, you will modify the code for the cypher function from Exercise 1 so that the application can now cypher a message using a keyword of arbitrary length. 
201 201
 
202 202
 #### Instructions
203 203
 
204
-1. Modify the implementation of the `cypher` function so that it can cipher a message with a keyword of any (non-zero) length. For this exercise the message may contain any character (including non alphabetical characters). The keyword must consist exclusively of letters. 
204
+1. Modify the implementation of the `cypher` function so that it can cypher a message with a keyword of any (non-zero) length. For this exercise the message may contain any character (including non alphabetical characters). The keyword must consist exclusively of letters. 
205 205
 
206 206
     Whenever the character in the cleartext is not a letter it will not be ciphered, as seen in Figure 7. If any character in the keyword is not a letter, the ciphered message will be (literally) `”CLAVE INVALIDA”`. 
207 207
 
@@ -213,7 +213,7 @@ In this exercise, you will modify the code for the cypher function from Exercise
213 213
     | ciphered text   | H | Y | @ | X | K | * | T |   | K | 8 | A | Z |
214 214
 
215 215
 
216
-    **Figure 7.** Example Vigenere cipher of the cleartext `“PR@GR*M T8IS”` using the keyword `SHORT”`. 
216
+    **Figure 7.** Example Vigenere cypher of the cleartext `“PR@GR*M T8IS”` using the keyword `SHORT”`. 
217 217
 
218 218
     ---
219 219