Selaa lähdekoodia

Updates README-en.md

Auto commit by GitBook Editor
Anonymous 8 vuotta sitten
vanhempi
commit
6a63a5ee3c
1 muutettua tiedostoa jossa 321 lisäystä ja 321 poistoa
  1. 321
    321
      README-en.md

+ 321
- 321
README-en.md Näytä tiedosto

@@ -1,321 +1,321 @@
1
-# Repetition Structures - Steganography
2
-
3
-![main1.png](images/main1.png)
4
-![main2.png](images/main2.png)
5
-![main3.png](images/main3.png)
6
-
7
-
8
-
9
-One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. These structures are also referred to as *repetition structures*. In today's laboratory experience, you will complete a steganography application to practice the use of nested loops and the manipulation of bidimensional arrays.
10
-
11
-##Objectives:
12
-
13
-1. Apply nested loops and decision structures to manipulate bidimensional arrays and extract messages hidden in images.
14
-
15
-2. Use modular programming.
16
-
17
-3. Use the binary representation of characters.
18
-
19
-
20
-## Pre-Lab:
21
-
22
-Before coming to the laboratory session you should have:
23
-
24
-1. Reviewed the basic concepts related to repetition structures, bidimensional arrays and decision structures.
25
-
26
-2. Studied the concepts of the color composition of pixels in images.
27
-
28
-3. Studied the binary representation of characters.
29
-
30
-4. Reviewed the string manipulation methods.
31
-
32
-5. Studied the concepts and instructions related to the laboratory session.
33
-
34
-6. Taken the Pre-Lab quiz, available in Moodle.
35
-
36
----
37
-
38
----
39
-
40
-
41
-## Steganography
42
-
43
-Steganography is the science of camouflaging the presence of hidden messages in legitimate carriers (seemingly harmless files). This science has been used by cybercriminals to inflict damage to computer systems and by (old style) terrorists to encode hidden messages transmitted through the internet. There is claim that Al-Qaeda may have used steganography to encode messages into images, and then transport them via e-mail, and possibly via USENET, to prepare and execute the September 11, 2001 terrorist attack. 
44
-
45
-Steganography has some lawful uses too [1]:
46
-
47
-* A medical imaging laboratory can embed a patient's information into the images, thus preventing against fraud and/or patient misdiagnosis. 
48
-* We can use hidden information to identify the legitimate owner of a document or image. If the document is leaked, or distributed to unauthorized parties, one can trace it back to the rightful owner and perhaps discover which party broke the license distribution agreement.
49
-
50
-In this laboratory experience, you will implement a simple algorithm to extract hidden messages from steganography images.
51
-
52
----
53
-
54
-## Image Editing
55
-
56
-In this laboratory experience, you will recover secret messages that have been hidden in an image. To be able to carry out your task, you should understand some concepts related to images, be familiar with the methods of the `QImage` class in `Qt`,  and using functions that works with data of type `QRgb`.
57
-
58
-### Pixels
59
-
60
-The smallest element in an image is called *pixel*. This unit consists of a single color. Since each color is a combination of tones for the primary red, green and blue colors, it is coded as an unsigned integer whose bytes represent the tones of red, green and blue of the pixel (Figure 1). This combination is called the color's *RGB* which is an acronym for "Red-Green-Blue". For example, a pure red pixel has an RGB representation of `0x00ff0000`, while a white pixel has an RGB representation of `0x00FFFFFF` (since the color white is a combination of tones of red, green and blue in all of their intensity).
61
-
62
----
63
-
64
-![figure1.png](images/figure1.png)
65
-
66
-**Figure 1.** Bit distribution for the tones of red, green and blue in an RGB representation. Each tone can have values between 0x00 (the eight bits in 0) and 0xFF (the 8 bits in 1).
67
-
68
----
69
-
70
-`Qt` uses the `QRgb` type to represent `RGB` values. Using the functions that are described below we can perform important operations to analyze images, such as obtaining the RGB of each pixel in an image, and to obtain the red, green and blue components of the `QRgb` value of the pixel.
71
-
72
-### Library
73
-
74
-In today's laboratory experience, you will use the `QImage` class. This class allows you to access the data in the pixels of an image to manipulate it. The documentation for the `QImage` class can be found in http://doc.qt.io/qt-4.8/qimage.html.
75
-
76
-The code provided in the file  `steganography.cpp`  contains the following objects of the `QImage` class:
77
-
78
-* `origImage`   // contains the information of the original image where the message was hidden
79
-*  `newImage`  // will contain the image with the hidden message
80
-
81
-The objects of the `QImage` class have the following methods that will be useful for today's laboratory experience:
82
-
83
-* `width()`      // returns the positive integer value for the image's width 
84
-* `height()`      // returns the positive integer value for the image's height 
85
-* `pixel(i, j)`       // returns the `QRgb` for the pixel in position `(i,j)`
86
-
87
-
88
-The following functions are useful to work with data of type `QRgb`:
89
-
90
-* `qRed(pixel)`   // returns the tone for the pixel's red color, i.e. a value between (0x00 and 0xFF)
91
-* `qGreen(pixel)` // returns the tone for the pixel's green color, i.e. a value between (0x00 and 0xFF)
92
-* `qBlue(pixel)`  // returns the tone for the pixel's blue color, i.e. a value between (0x00 and 0xFF)
93
-
94
-
95
-
96
-#### Examples:
97
-
98
-1. If the following `4 x 4` image of pixels represents the object `origImage`,
99
-
100
-    ![ejemplo.png](images/ejemplo.png)
101
-
102
-    then `origImage.pixel(2,1)` returns the `rgb` value that represents the color blue ( `0x0000ff`).
103
-
104
-2. The following instruction assigns to `greenContent` the value of the green tone that is contained in the pixel `(1,1)` of `origImage`:
105
-
106
-    `int greenContent = qGreen(origImage.pixel(1,1));`.
107
-
108
-3. The following program creates an object of class `QImage`  and prints the red, green and blue components of the pixel in the center of the image. The image used is the one specified within the parenthesis during the creation of the object, that is, the file `chuck.png`.
109
-
110
-     ---
111
-     
112
-         #include <QImage>
113
-         #include <iostream>
114
-
115
-         using namespace std;
116
-         int main() {
117
-           QImage myImage(“/Users/rarce/Downloads/chuck.png”);
118
-           QRgb    centralPixel;
119
-
120
-           centralPixel = myImage.pixel(myImage.width() / 2, myImage.height() / 2);
121
-
122
-           cout << hex;
123
-
124
-           cout << “The red, green and blue components of the middle pixel are: “
125
-                << qRed(centralPixel) << “, “
126
-                << qGreen(centralPixel) << “, “
127
-                << qBlue(centralPixel) << endl;
128
-           return 0;
129
-         }
130
-    
131
-
132
-     ---
133
-
134
-
135
-### Embedding a message into an image
136
-
137
-One of the simplest methods of *hidding* a message in an image is by encoding the message into the least significant bits of the image pixel's colors. This method effectively hides the message in the image because changing the least significant bit of a 8-bit color is barely noticeable by the human observer.  
138
-
139
-For example, Figure 2 shows two huge pixels, the one on the left has color `0xff0000` and the one on the right has color `0xfe0101`. Recall that the most significant **byte** (i.e. the two leftmost hex digits) represents the intensity of the red color, the second **byte** represents the intensity of the green color, and the least significant **byte** represents the intensity of the blue color. In Figure 2, the least significant **bits** of the red, green and blue components of the two pixels are different, yet, they look the same color. The pixel on the right is the result of encoding the three bit message `011` into the original pixel's least significant bits (of each color). That is, encode the `0` in the least significant bit of the red component, encode the `1` in the least significant bit of the green component, and encode the `1` in the least significant bit of the blue component in the pixel.
140
-
141
----
142
-
143
-![figure2.png](images/figure2.png)
144
-
145
-**Figure 2.** The left square represents a pixel of color `0xff0000`. The right square represents a pixel of color `0xfe0101`.
146
-
147
----
148
-
149
-
150
-Let's illustrate the embedding procedure of the word "Dog" into the following image:
151
-
152
-![main3.png](images/main3.png)
153
-
154
-Assume that each square is a pixel of the image. 
155
-
156
-The first step would be to obtain the ASCII representation of the message. The bits of the ASCII representation are the bits we will encode into the colors of the pixels. The ASCII representation of `Dog` is:
157
-
158
-`"Dog"  = 01000100 01101111 01100111`
159
-
160
-The code `0100 0100` corresponds to the `D`, and so forth.
161
-
162
-The encoding procedure it is easier to understand if we separate the bits into groups of three (one bit for each RGB component):
163
-
164
-`"Dog"  = 010 001 000 110 111 101 100 111`
165
-
166
-Next, we start traversing the image pixel by pixel, embedding in each pixel three bits from the ASCII code (one bit in each pixel's color component). For instance, we would embed `010` in the first pixel, `001` in the second, and so forth.
167
-
168
-We may do the following to embed each trio of bits `b2, b1, b0`:
169
-
170
-```
171
-Input: p: a pixel
172
-  b2,b1,b0: the trio of bits
173
-Output: modifiedPixel: the pixel with the embedded trio
174
-========
175
-1. r = red component of p 
176
-2. g = green component of p
177
-3. b = blue component of p
178
-4. clear the least significant bits of r,g,b
179
-5. the red component of modifiedPixel will contain b2 substituted in the least significant bit of r
180
-6. the green component of modifiedPixel will contain b1 substituted in the least significant bit of g
181
-7. the blue component of modifiedPixel will contain b0 substituted in the least significant bit of b
182
-```
183
-
184
-For example, say that you are embedding the bit trio `011` into a pixel whose color code is `0xa5b6c7`. The algorithm would compute as follows:
185
-
186
-
187
-```
188
-1. r = 0x10100101  // this is 0xa5
189
-2. g = 0x10110110  // this is 0xb6
190
-3. b = 0x11000111  // this is 0xc7
191
-4. clear the least significant bits of r,g,b
192
-   r becomes 0x10100100
193
-   g becomes 0x10110110
194
-   b becomes 0x11000110
195
-5. the red component of the modifiedPixel will be 0x10100100 (that is, 0xa4)
196
-6. the green component of the modifiedPixel will be 0x10110111 (that is 0xb7)
197
-7. the blue component of the modifiedPixel will be 0x11000111 (that is 0xc7)
198
-
199
-the modifiedPixel color code will be 0xa4b7c7
200
-```
201
-
202
-The following is the image after the word "Dog" was embedded.
203
-
204
-![figure3.png](images/figure3.png)
205
-
206
-Only the color of the first 8 pixels was modified, since the combined ASCII code for "Dog" was 24 bits long.
207
-
208
-The following are the color codes for first eight pixels of the original and modified images:
209
-
210
-
211
-
212
-|  Original Image pixel  |  Bit trio  |  Modified image pixel |
213
-|---|---|---|
214
-| `0x99 99 99` | `010`  | `0x98 99 98`  |
215
-| `0x00 00 00` | `001`  | `0x00 00 01`  |
216
-| `0x00 00 00` | `000`  | `0x00 00 00`  |
217
-| `0x00 00 00` | `110`  | `0x01 01 00`  |
218
-| `0x00 00 00` | `111`  | `0x01 01 01`  |
219
-| `0x00 00 00` | `101`  | `0x01 00 01`  |
220
-| `0x00 00 00` | `100`  | `0x01 00 00`  |
221
-| `0x00 00 00` | `111`  | `0x01 01 01`  |
222
-
223
-
224
-Question: 
225
-What message is hidden (using the least significant bit technique) in an image whose first 8 pixels are:
226
-
227
-`0x545554 0x666667 0x444544 0x333232 0xff0000 0x0100ff 0x00ff00 0x10aaba`
228
-
229
-Explain your answer.
230
-
231
-
232
----
233
-
234
----
235
-
236
-
237
-
238
-!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-05.html"
239
-<br>
240
-
241
-
242
-
243
----
244
-
245
----
246
-
247
-
248
-## Laboratory Session:
249
-
250
-In today's laboratory experience, you will complete a steganography application to extract hidden messages from images.
251
-
252
-### Exercise 1 - Extract the Binary Message
253
-
254
-#### Instructions
255
-
256
-1. Load the project  `Steganography` into `QtCreator`. There are two ways to do this:
257
-
258
-    * Using the virtual machine: Double click the file `Steganography.pro` located in the folder `/home/eip/labs/repetitions-steganography` of your virtual machine.
259
-    * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/repetitions-steganography` to download the folder `repetitions-steganography` from `Bitbucket`. Double click the file `Steganography.pro` located in the folder that you downloaded to your computer.
260
-
261
-    The project contains the skeleton for an application to recover embedded messages from images. The messages that you will be recovering have been  embedded using the least significant bit technique. The end of each message was encoded by using the ASCII character with binary code `00000000`. 
262
-
263
-2. Compile and run the program. You should obtain an interface that looks similar to:
264
-
265
-     ![img1.png](images/img1.png)
266
-
267
-3. The button `Load Image` has already been programmed to allow the user to load an image and display it. Your task is to program the functionality of the button `Retrieve Message` so that it analyzes the image and extracts the hidden message. The hidden message should be displayed in the `Write a message` window.
268
-
269
-4. You will be working with the `steganography.cpp` file. Complete the `ExtractMessage` function that receives a steganography image so it extracts the digits of the binary message encoded in the image and stores them in a string. The function should invoke another function `binaryStringToMessage` that converts the string from `0`'s and `1`'s in the message's characters and returns the hidden message.
270
-
271
-    For example, if the first few pixels the image were these:
272
-
273
-    `0x98 99 98 0x00 00 01 0x00 00 00 0x01 01 00 0x01 01 01 0x01 00 01 0x01 00 00 0x01 01 01 0xf0 ea 00 0x44 00 f0 0x00 aa 22 . . .`,
274
-
275
-    your `ExtractMessage` function would extract the least significant bits of each colors component and construct the `string`: `"010001000110111101100111000000000.."`.
276
-
277
-
278
-    Notice that your algorithm should have some mechanism for detecting if the last 8 character block were all `0`. When this happens, the algorithm should stop reading the pixels.
279
-
280
-    The string of binary digits should then be sent to another function `binaryStringToMessage` (see Exercise 2) that interprets the `0`'s and `1`'s as the bits of ASCII characters. In the example above, the string `"010001000110111101100111000000000"` would be decoded to "Dog" (because `01000100` corresponds to 'D', `01101111` is 'o',  `01100111` is 'g', and a `00000000` symbolizes the end of the string.)
281
-
282
-    To implement the algorithm for extracting the message, you should understand how the message was encoded. If necessary, review the "Embedding a message into an image" section.
283
-
284
-
285
-### Exercise 2 - Interpreting the Message
286
-
287
-#### Instructions
288
-
289
-1. Complete the `binaryStringToMessage` function that receives the string of `0`'s and `1`'s extracted from the image so it returns the hidden message. You can use the `binStringToChar` function to convert substrings of 8 `0`'s and `1`'s in its corresponding character.
290
-
291
-2. Test your code using the following images:
292
-
293
-    * `pug.png`, contains the message "Hello World !"
294
-    * `uprTorre.png`, contains the message "CCOM3033 - Steganography Lab Rules!!!"
295
-
296
-3. Once you validate your program using the test images, use the program to analyze the following images. 
297
-
298
-    * `gallito.png`
299
-    * `puppy.png`
300
-    * `vacas.png`
301
-
302
-
303
----
304
-
305
----
306
-
307
-##Deliverables
308
-
309
-Use "Deliverable" in Moodle to upload the `steganography.cpp` file that contains the `ExtractMessage` and `binaryStringToMessage` functions. Remember to use good programming techniques, include the names of the programmers involved, and document your program.
310
-
311
----
312
-
313
----
314
-
315
-
316
-##References 
317
-
318
-[1] Rocha, Anderson, and Siome Goldenstein. "Steganography and steganalysis in digital multimedia: Hype or hallelujah?." Revista de Informática Teórica e Aplicada 15.1 (2008): 83-110.
319
-
320
-
321
-
1
+# Repetition Structures - Steganography
2
+
3
+![main1.png](images/main1.png)
4
+![main2.png](images/main2.png)
5
+![main3.png](images/main3.png)
6
+
7
+
8
+
9
+One of the advantages of using computer programs is that we can easily implement repetitive tasks. Structures such as the `for`, `while`, and `do-while` allow us to repeat a block of instructions as many times as needed. These structures are also referred to as *repetition structures*. In today's laboratory experience, you will complete a steganography application to practice the use of nested loops and the manipulation of bidimensional arrays.
10
+
11
+##Objectives:
12
+
13
+1. Apply nested loops and decision structures to manipulate bidimensional arrays and extract messages hidden in images.
14
+
15
+2. Use modular programming.
16
+
17
+3. Use the binary representation of characters.
18
+
19
+
20
+## Pre-Lab:
21
+
22
+Before coming to the laboratory session you should have:
23
+
24
+1. Reviewed the basic concepts related to repetition structures, bidimensional arrays and decision structures.
25
+
26
+2. Studied the concepts of the color composition of pixels in images.
27
+
28
+3. Studied the binary representation of characters.
29
+
30
+4. Reviewed the string manipulation methods.
31
+
32
+5. Studied the concepts and instructions related to the laboratory session.
33
+
34
+6. Taken the Pre-Lab quiz, available in Moodle.
35
+
36
+---
37
+
38
+---
39
+
40
+
41
+## Steganography
42
+
43
+Steganography is the science of camouflaging the presence of hidden messages in legitimate carriers (seemingly harmless files). This science has been used by cybercriminals to inflict damage to computer systems and by (old style) terrorists to encode hidden messages transmitted through the internet. There is claim that Al-Qaeda may have used steganography to encode messages into images, and then transport them via e-mail, and possibly via USENET, to prepare and execute the September 11, 2001 terrorist attack. 
44
+
45
+Steganography has some lawful uses too [1]:
46
+
47
+* A medical imaging laboratory can embed a patient's information into the images, thus preventing against fraud and/or patient misdiagnosis. 
48
+* We can use hidden information to identify the legitimate owner of a document or image. If the document is leaked, or distributed to unauthorized parties, one can trace it back to the rightful owner and perhaps discover which party broke the license distribution agreement.
49
+
50
+In this laboratory experience, you will implement a simple algorithm to extract hidden messages from steganography images.
51
+
52
+---
53
+
54
+## Image Editing
55
+
56
+In this laboratory experience, you will recover secret messages that have been hidden in an image. To be able to carry out your task, you should understand some concepts related to images, be familiar with the methods of the `QImage` class in `Qt`,  and using functions that works with data of type `QRgb`.
57
+
58
+### Pixels
59
+
60
+The smallest element in an image is called *pixel*. This unit consists of a single color. Since each color is a combination of tones for the primary red, green and blue colors, it is coded as an unsigned integer whose bytes represent the tones of red, green and blue of the pixel (Figure 1). This combination is called the color's *RGB* which is an acronym for "Red-Green-Blue". For example, a pure red pixel has an RGB representation of `0x00ff0000`, while a white pixel has an RGB representation of `0x00FFFFFF` (since the color white is a combination of tones of red, green and blue in all of their intensity).
61
+
62
+---
63
+
64
+![figure1.png](images/figure1.png)
65
+
66
+**Figure 1.** Bit distribution for the tones of red, green and blue in an RGB representation. Each tone can have values between 0x00 (the eight bits in 0) and 0xFF (the 8 bits in 1).
67
+
68
+---
69
+
70
+`Qt` uses the `QRgb` type to represent `RGB` values. Using the functions that are described below we can perform important operations to analyze images, such as obtaining the RGB of each pixel in an image, and to obtain the red, green and blue components of the `QRgb` value of the pixel.
71
+
72
+### Library
73
+
74
+In today's laboratory experience, you will use the `QImage` class. This class allows you to access the data in the pixels of an image to manipulate it. The documentation for the `QImage` class can be found in http://doc.qt.io/qt-4.8/qimage.html.
75
+
76
+The code provided in the file  `steganography.cpp`  contains the following objects of the `QImage` class:
77
+
78
+* `origImage`   // contains the information of the original image where the message was hidden
79
+*  `newImage`  // will contain the image with the hidden message
80
+
81
+The objects of the `QImage` class have the following methods that will be useful for today's laboratory experience:
82
+
83
+* `width()`      // returns the positive integer value for the image's width 
84
+* `height()`      // returns the positive integer value for the image's height 
85
+* `pixel(i, j)`       // returns the `QRgb` for the pixel in position `(i,j)`
86
+
87
+
88
+The following functions are useful to work with data of type `QRgb`:
89
+
90
+* `qRed(pixel)`   // returns the tone for the pixel's red color, i.e. a value between (0x00 and 0xFF)
91
+* `qGreen(pixel)` // returns the tone for the pixel's green color, i.e. a value between (0x00 and 0xFF)
92
+* `qBlue(pixel)`  // returns the tone for the pixel's blue color, i.e. a value between (0x00 and 0xFF)
93
+
94
+
95
+
96
+#### Examples:
97
+
98
+1. If the following `4 x 4` image of pixels represents the object `origImage`,
99
+
100
+    ![ejemplo.png](images/ejemplo.png)
101
+
102
+    then `origImage.pixel(2,1)` returns the `rgb` value that represents the color blue ( `0x0000ff`).
103
+
104
+2. The following instruction assigns to `greenContent` the value of the green tone that is contained in the pixel `(1,1)` of `origImage`:
105
+
106
+    `int greenContent = qGreen(origImage.pixel(1,1));`.
107
+
108
+3. The following program creates an object of class `QImage`  and prints the red, green and blue components of the pixel in the center of the image. The image used is the one specified within the parenthesis during the creation of the object, that is, the file `chuck.png`.
109
+
110
+     ---
111
+
112
+```cpp     
113
+#include <QImage>
114
+#include <iostream>
115
+
116
+using namespace std;
117
+int main() {
118
+     QImage myImage(“/Users/rarce/Downloads/chuck.png”);
119
+     QRgb centralPixel;
120
+
121
+     centralPixel = myImage.pixel(myImage.width() / 2, myImage.height() / 2);
122
+
123
+     cout << hex;
124
+
125
+     cout << “The red, green and blue components of the middle pixel are: “
126
+          << qRed(centralPixel) << “, “
127
+          << qGreen(centralPixel) << “, “
128
+          << qBlue(centralPixel) << endl;
129
+     return 0;
130
+}
131
+```    
132
+
133
+     ---
134
+
135
+
136
+### Embedding a message into an image
137
+
138
+One of the simplest methods of *hidding* a message in an image is by encoding the message into the least significant bits of the image pixel's colors. This method effectively hides the message in the image because changing the least significant bit of a 8-bit color is barely noticeable by the human observer.  
139
+
140
+For example, Figure 2 shows two huge pixels, the one on the left has color `0xff0000` and the one on the right has color `0xfe0101`. Recall that the most significant **byte** (i.e. the two leftmost hex digits) represents the intensity of the red color, the second **byte** represents the intensity of the green color, and the least significant **byte** represents the intensity of the blue color. In Figure 2, the least significant **bits** of the red, green and blue components of the two pixels are different, yet, they look the same color. The pixel on the right is the result of encoding the three bit message `011` into the original pixel's least significant bits (of each color). That is, encode the `0` in the least significant bit of the red component, encode the `1` in the least significant bit of the green component, and encode the `1` in the least significant bit of the blue component in the pixel.
141
+
142
+---
143
+
144
+![figure2.png](images/figure2.png)
145
+
146
+**Figure 2.** The left square represents a pixel of color `0xff0000`. The right square represents a pixel of color `0xfe0101`.
147
+
148
+---
149
+
150
+
151
+Let's illustrate the embedding procedure of the word "Dog" into the following image:
152
+
153
+![main3.png](images/main3.png)
154
+
155
+Assume that each square is a pixel of the image. 
156
+
157
+The first step would be to obtain the ASCII representation of the message. The bits of the ASCII representation are the bits we will encode into the colors of the pixels. The ASCII representation of `Dog` is:
158
+
159
+`"Dog"  = 01000100 01101111 01100111`
160
+
161
+The code `0100 0100` corresponds to the `D`, and so forth.
162
+
163
+The encoding procedure it is easier to understand if we separate the bits into groups of three (one bit for each RGB component):
164
+
165
+`"Dog"  = 010 001 000 110 111 101 100 111`
166
+
167
+Next, we start traversing the image pixel by pixel, embedding in each pixel three bits from the ASCII code (one bit in each pixel's color component). For instance, we would embed `010` in the first pixel, `001` in the second, and so forth.
168
+
169
+We may do the following to embed each trio of bits `b2, b1, b0`:
170
+
171
+```
172
+Input:  p: a pixel
173
+        b2,b1,b0: the trio of bits
174
+Output: modifiedPixel: the pixel with the embedded trio
175
+========================================================
176
+1. r = red component of p 
177
+2. g = green component of p
178
+3. b = blue component of p
179
+4. clear the least significant bits of r,g,b
180
+5. the red component of modifiedPixel will contain b2 substituted in the least significant bit of r
181
+6. the green component of modifiedPixel will contain b1 substituted in the least significant bit of g
182
+7. the blue component of modifiedPixel will contain b0 substituted in the least significant bit of b
183
+```
184
+
185
+For example, say that you are embedding the bit trio `011` into a pixel whose color code is `0xa5b6c7`. The algorithm would compute as follows:
186
+
187
+
188
+```
189
+1. r = 0x10100101  // this is 0xa5
190
+2. g = 0x10110110  // this is 0xb6
191
+3. b = 0x11000111  // this is 0xc7
192
+4. clear the least significant bits of r,g,b
193
+   r becomes 0x10100100
194
+   g becomes 0x10110110
195
+   b becomes 0x11000110
196
+5. the red component of the modifiedPixel will be 0x10100100 (that is, 0xa4)
197
+6. the green component of the modifiedPixel will be 0x10110111 (that is 0xb7)
198
+7. the blue component of the modifiedPixel will be 0x11000111 (that is 0xc7)
199
+
200
+the modifiedPixel color code will be 0xa4b7c7
201
+```
202
+
203
+The following is the image after the word "Dog" was embedded.
204
+
205
+![figure3.png](images/figure3.png)
206
+
207
+Only the color of the first 8 pixels was modified, since the combined ASCII code for "Dog" was 24 bits long.
208
+
209
+The following are the color codes for first eight pixels of the original and modified images:
210
+
211
+
212
+
213
+|  Original Image pixel  |  Bit trio  |  Modified image pixel |
214
+|---|---|---|
215
+| `0x99 99 99` | `010`  | `0x98 99 98`  |
216
+| `0x00 00 00` | `001`  | `0x00 00 01`  |
217
+| `0x00 00 00` | `000`  | `0x00 00 00`  |
218
+| `0x00 00 00` | `110`  | `0x01 01 00`  |
219
+| `0x00 00 00` | `111`  | `0x01 01 01`  |
220
+| `0x00 00 00` | `101`  | `0x01 00 01`  |
221
+| `0x00 00 00` | `100`  | `0x01 00 00`  |
222
+| `0x00 00 00` | `111`  | `0x01 01 01`  |
223
+
224
+
225
+Question: 
226
+What message is hidden (using the least significant bit technique) in an image whose first 8 pixels are:
227
+
228
+`0x545554 0x666667 0x444544 0x333232 0xff0000 0x0100ff 0x00ff00 0x10aaba`
229
+
230
+Explain your answer.
231
+
232
+
233
+---
234
+
235
+---
236
+
237
+
238
+
239
+!INCLUDE "../../eip-diagnostic/steganography/en/diag-steganography-05.html"
240
+<br>
241
+
242
+
243
+
244
+---
245
+
246
+---
247
+
248
+
249
+## Laboratory Session:
250
+
251
+In today's laboratory experience, you will complete a steganography application to extract hidden messages from images.
252
+
253
+### Exercise 1 - Extract the Binary Message
254
+
255
+#### Instructions
256
+
257
+1. Load the project  `Steganography` into `QtCreator`. There are two ways to do this:
258
+
259
+    * Using the virtual machine: Double click the file `Steganography.pro` located in the folder `/home/eip/labs/repetitions-steganography` of your virtual machine.
260
+    * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/repetitions-steganography` to download the folder `repetitions-steganography` from `Bitbucket`. Double click the file `Steganography.pro` located in the folder that you downloaded to your computer.
261
+
262
+    The project contains the skeleton for an application to recover embedded messages from images. The messages that you will be recovering have been  embedded using the least significant bit technique. The end of each message was encoded by using the ASCII character with binary code `00000000`. 
263
+
264
+2. Compile and run the program. You should obtain an interface that looks similar to:
265
+
266
+     ![img1.png](images/img1.png)
267
+
268
+3. The button `Load Image` has already been programmed to allow the user to load an image and display it. Your task is to program the functionality of the button `Retrieve Message` so that it analyzes the image and extracts the hidden message. The hidden message should be displayed in the `Write a message` window.
269
+
270
+4. You will be working with the `steganography.cpp` file. Complete the `ExtractMessage` function that receives a steganography image so it extracts the digits of the binary message encoded in the image and stores them in a string. The function should invoke another function `binaryStringToMessage` that converts the string from `0`'s and `1`'s in the message's characters and returns the hidden message.
271
+
272
+    For example, if the first few pixels the image were these:
273
+
274
+    `0x98 99 98 0x00 00 01 0x00 00 00 0x01 01 00 0x01 01 01 0x01 00 01 0x01 00 00 0x01 01 01 0xf0 ea 00 0x44 00 f0 0x00 aa 22 . . .`,
275
+
276
+    your `ExtractMessage` function would extract the least significant bits of each colors component and construct the `string`: `"010001000110111101100111000000000.."`.
277
+
278
+    Notice that your algorithm should have some mechanism for detecting if the last 8 character block were all `0`. When this happens, the algorithm should stop reading the pixels.
279
+
280
+    The string of binary digits should then be sent to another function `binaryStringToMessage` (see Exercise 2) that interprets the `0`'s and `1`'s as the bits of ASCII characters. In the example above, the string `"010001000110111101100111000000000"` would be decoded to "Dog" (because `01000100` corresponds to 'D', `01101111` is 'o',  `01100111` is 'g', and a `00000000` symbolizes the end of the string.)
281
+
282
+    To implement the algorithm for extracting the message, you should understand how the message was encoded. If necessary, review the "Embedding a message into an image" section.
283
+
284
+
285
+### Exercise 2 - Interpreting the Message
286
+
287
+#### Instructions
288
+
289
+1. Complete the `binaryStringToMessage` function that receives the string of `0`'s and `1`'s extracted from the image so it returns the hidden message. You can use the `binStringToChar` function to convert substrings of 8 `0`'s and `1`'s in its corresponding character.
290
+
291
+2. Test your code using the following images:
292
+
293
+    * `pug.png`, contains the message "Hello World !"
294
+    * `uprTorre.png`, contains the message "CCOM3033 - Steganography Lab Rules!!!"
295
+
296
+3. Once you validate your program using the test images, use the program to analyze the following images. 
297
+
298
+    * `gallito.png`
299
+    * `puppy.png`
300
+    * `vacas.png`
301
+
302
+
303
+---
304
+
305
+---
306
+
307
+##Deliverables
308
+
309
+Use "Deliverable" in Moodle to upload the `steganography.cpp` file that contains the `ExtractMessage` and `binaryStringToMessage` functions. Remember to use good programming techniques, include the names of the programmers involved, and document your program.
310
+
311
+---
312
+
313
+---
314
+
315
+
316
+##References 
317
+
318
+[1] Rocha, Anderson, and Siome Goldenstein. "Steganography and steganalysis in digital multimedia: Hype or hallelujah?." Revista de Informática Teórica e Aplicada 15.1 (2008): 83-110.
319
+
320
+
321
+