|
@@ -1,18 +1,4 @@
|
1
|
1
|
/// \file
|
2
|
|
-// RAN 2014-06-10:
|
3
|
|
-// -- Simplified the changeMask function.
|
4
|
|
-// -- Simplified the masking in the EmbbedMessage function.
|
5
|
|
-// -- Changed EmbbedMessage so that only the pixels needed to embbed the message
|
6
|
|
-// are changed. Previously, all pixels were masked. This involved hardcoding a
|
7
|
|
-// postfix into the encodded message that repeats ASCII code 0 ten times.
|
8
|
|
-
|
9
|
|
-// RAN 2014-06-14:
|
10
|
|
-// -- Simplified the end of message encoding and decoding. Now it just encodes one '\0'
|
11
|
|
-// char at the end of the string. Also, its stops decoding when it finds a '\0'
|
12
|
|
-
|
13
|
|
-// RAN 2015-06-30
|
14
|
|
-// -- In the functions binaryStringToMessage and ExtractMessage, changed
|
15
|
|
-// string additions to character push_back.
|
16
|
2
|
|
17
|
3
|
|
18
|
4
|
#include "steganography.h"
|
|
@@ -21,36 +7,11 @@ Steganography::Steganography()
|
21
|
7
|
{
|
22
|
8
|
}
|
23
|
9
|
|
24
|
|
-/// \fn int cbtoi(char c)
|
25
|
|
-/// \~English
|
26
|
|
-/// \brief Converts a character bit to integer.
|
27
|
|
-/// \param c a character ('0' or '1'), the char that will be converted
|
28
|
|
-/// \return An integer 1 or 0
|
29
|
|
-/// \~Spanish
|
30
|
|
-/// \brief Convierte un bit en caracter a entero.
|
31
|
|
-/// \param c un caracter ('0' o '1'), el caracter que se va a convertir.
|
32
|
|
-/// \return Un entero 1 o 0
|
33
|
|
-///
|
34
|
10
|
int cbtoi(char c){
|
35
|
11
|
if(c == '0') return 0;
|
36
|
12
|
else return 1 ;
|
37
|
13
|
}
|
38
|
14
|
|
39
|
|
-/// \fn string decToBin(int num, int pad)
|
40
|
|
-/// \~English
|
41
|
|
-/// \brief Converts an decimal number to a string in base 2.
|
42
|
|
-/// \param num a non-negative integer, the number that will be converted
|
43
|
|
-/// \param pad a non-negative integer, the number of digits
|
44
|
|
-/// in the resulting string
|
45
|
|
-/// \return A string of length pad of 0's and/or 1's.
|
46
|
|
-/// \~Spanish
|
47
|
|
-/// \brief Convierte un numero entero a una cadena de caracteres
|
48
|
|
-/// en base 2.
|
49
|
|
-/// \param num un entero positivo, el numero que se va a convertir.
|
50
|
|
-/// \param pad un entero positivo, el numero de digitos en la cadena de
|
51
|
|
-/// caracteres resultante.
|
52
|
|
-/// \return Una cadena de caracteres de largo pad de 0's y/o 1's
|
53
|
|
-///
|
54
|
15
|
string decToBin(int num, int pad)
|
55
|
16
|
{
|
56
|
17
|
int r = 0; // residue
|
|
@@ -81,29 +42,6 @@ string decToBin(int num, int pad)
|
81
|
42
|
}
|
82
|
43
|
|
83
|
44
|
|
84
|
|
-/// \fn string messageToBinaryString(string str)
|
85
|
|
-/// \~English
|
86
|
|
-/// \brief Converts a string to a string of 1's and 0's
|
87
|
|
-/// that represent the ASCII codes of the characters in the original string.
|
88
|
|
-/// For example, "AB" results in "10000011000010".
|
89
|
|
-/// [-----][-----]
|
90
|
|
-/// ^ ^
|
91
|
|
-/// ASCII code of A | |
|
92
|
|
-/// ASCII code of B --------+
|
93
|
|
-///
|
94
|
|
-/// \param str a string of characters to be converted to their ASCII representations
|
95
|
|
-/// \return A string of 0's and/or 1's.
|
96
|
|
-/// \~Spanish
|
97
|
|
-/// \brief Convierte una caena de caracteres a una cadena de 1's y 0's
|
98
|
|
-/// que representa el codigo ASCII de los caracteren en la cadena original.
|
99
|
|
-/// Por ejemplo, "AB" resulta in "10000011000010".
|
100
|
|
-/// [-----][-----]
|
101
|
|
-/// ^ ^
|
102
|
|
-/// Codigo ASCII de A | |
|
103
|
|
-/// Codigo ASCII de B --------+
|
104
|
|
-/// \param str una cadena de caracteres a ser convertido a su representacion ASCII
|
105
|
|
-/// \return Una cadena de 0's y/o 1's.
|
106
|
|
-///
|
107
|
45
|
string messageToBinaryString(string str){
|
108
|
46
|
string binStr = "";
|
109
|
47
|
int temp;
|
|
@@ -119,19 +57,6 @@ string messageToBinaryString(string str){
|
119
|
57
|
return binStr ;
|
120
|
58
|
}
|
121
|
59
|
|
122
|
|
-/// \fn char binStringToChar(string str)
|
123
|
|
-/// \~English
|
124
|
|
-/// \brief binStringToChar: Converts a string of 0's and 1's to an caracter
|
125
|
|
-/// Example, with str="0011", returns the caracter 3.///
|
126
|
|
-/// \param str: a string of 0's and 1's
|
127
|
|
-/// \return A character whose binary representation is equivalent
|
128
|
|
-/// to the string.
|
129
|
|
-/// \~Spanish
|
130
|
|
-/// \brief Convierte una cadena de 0's y 1's a un caracter.
|
131
|
|
-/// Ejemplo, con str="00000011", devuelve el caracter 3.
|
132
|
|
-/// \param str una cadena de 0's y 1's
|
133
|
|
-/// \return Un caracter ASCII cuya representacion binaria es equivalente a la cadena str.
|
134
|
|
-///
|
135
|
60
|
char binStringToChar(string str){
|
136
|
61
|
|
137
|
62
|
int value = 0 ;
|
|
@@ -142,41 +67,10 @@ char binStringToChar(string str){
|
142
|
67
|
return static_cast<char>(value) ;
|
143
|
68
|
}
|
144
|
69
|
|
145
|
|
-/// \fn int createMask(int lbits)
|
146
|
|
-/// \~English
|
147
|
|
-/// \brief Creates a mask of lbit 1's in the least significant positions.
|
148
|
|
-/// Example, with lbits=4, returns the integer 15, which is mask 0x1111.
|
149
|
|
-/// \param lbits a non-negative integer, the number of bits to set to one
|
150
|
|
-/// \return An integer with lbit 1's in the least signicant positions.
|
151
|
|
-/// \~Spanish
|
152
|
|
-/// \brief Crea una mascara de lbit 1's en las posiciones menos significativas.
|
153
|
|
-/// Ejemplo, con lbits=4, devuelve el entero 15, cuya mascara es 0x1111.
|
154
|
|
-/// \param lbits un entero no negativo, el numero de bits a poner en uno.
|
155
|
|
-/// \return Un entero con lbit 1's en las posiciones menos significativas.
|
156
|
|
-///
|
157
|
70
|
int createMask(int lbits){
|
158
|
71
|
return (1 << lbits) - 1;
|
159
|
72
|
}
|
160
|
73
|
|
161
|
|
-
|
162
|
|
-/// \fn EmbbedMessage(const QImage & origImage, QImage & newImage, string msg)
|
163
|
|
-/// \~English
|
164
|
|
-/// \brief Given an image (origImage) will create a new image (&newImage) by
|
165
|
|
-/// embedding the bits of the msg into the least significant bits of
|
166
|
|
-/// pixel colors of the original image.
|
167
|
|
-/// \param origImage the original image will not be modified
|
168
|
|
-/// \param newImage the image that is created
|
169
|
|
-/// \param msg the string that will be embedded
|
170
|
|
-/// \return By reference, the newImage is returned, containing the embedded message
|
171
|
|
-/// \~Spanish
|
172
|
|
-/// \brief Dada una imagen (origImage) creara una imagen nueva(&newImage)
|
173
|
|
-/// empotrando los bits de el mensaje msg en los bits menos significativos de los
|
174
|
|
-/// colores de la imagen original.
|
175
|
|
-/// \param origImage la imagen original no va a ser modificada
|
176
|
|
-/// \param newImage la imagen que se crea
|
177
|
|
-/// \param msg la cadena que va a ser empotrada
|
178
|
|
-/// \return Por referencia, es devuelta newImage, conteniendo el mensaje empotrado.
|
179
|
|
-///
|
180
|
74
|
void EmbbedMessage(const QImage & origImage, QImage & newImage, string msg){
|
181
|
75
|
string binMsg ; // To store the message in binary.
|
182
|
76
|
// Para almacenar el mensaje en binario.
|
|
@@ -244,24 +138,6 @@ void EmbbedMessage(const QImage & origImage, QImage & newImage, string msg){
|
244
|
138
|
}
|
245
|
139
|
}
|
246
|
140
|
|
247
|
|
-/// \fn string binaryStringToMessage(string binStr)
|
248
|
|
-/// \~English
|
249
|
|
-/// \brief Converts a string of 0's and 1's to a string
|
250
|
|
-/// of characters.
|
251
|
|
-/// Example: with str="10000011000010", returns "AB", because
|
252
|
|
-/// 1000001 is ASCII of A, 1000010 is ASCII of B
|
253
|
|
-/// \param str a string of 0's and 1's
|
254
|
|
-/// \return A string that contains the characters whose ASCII codes
|
255
|
|
-/// where specified in the input string.
|
256
|
|
-/// \~Spanish
|
257
|
|
-/// \brief Convierte una cadena de 0's y 1's a una
|
258
|
|
-/// cadena de caracteres.
|
259
|
|
-/// Ejemplo: con str = "10000011000010", devuelve "AB", porque
|
260
|
|
-/// 1000001 es ASCII de A, 1000010 es ASCII de B
|
261
|
|
-/// \param str una cadena de 0's y 1's
|
262
|
|
-/// \return Una cadena que contiene los caracteres cuyos codigos ASCII
|
263
|
|
-/// estaban especificados en la cadena de entrada.
|
264
|
|
-///
|
265
|
141
|
string binaryStringToMessage(string binStr){
|
266
|
142
|
|
267
|
143
|
// YOUR CODE HERE
|
|
@@ -269,24 +145,9 @@ string binaryStringToMessage(string binStr){
|
269
|
145
|
}
|
270
|
146
|
|
271
|
147
|
|
272
|
|
-
|
273
|
|
-/// \fn string ExtractMessage(const QImage &stegoImage)
|
274
|
|
-/// \~English
|
275
|
|
-/// \brief Given an image (stegoImage) with the embedded message and the
|
276
|
|
-/// the number of bits embedded into each pixels colors, will
|
277
|
|
-/// extract the message that is hidden in the least significant
|
278
|
|
-/// bits of the stegoImage.
|
279
|
|
-/// \param stegoImage image that contains the embeded message
|
280
|
|
-/// \return A string containing the extracted message.
|
281
|
|
-/// \~Spanish
|
282
|
|
-/// \brief Dada una imagen (stegoImage) con un mensaje embedido y el numero
|
283
|
|
-/// numero de bits embedidios en cada color de los pixeles, va a extraer
|
284
|
|
-/// el mensaje que esta escondido en los bits menos significativos de la stegoImage
|
285
|
|
-/// \param stegoImage imagen que contiene el mensaje embedido
|
286
|
|
-/// \return Una cadena conteniendo el mensaje extraido.
|
287
|
|
-///
|
288
|
148
|
string ExtractMessage(const QImage &stegoImage){
|
289
|
149
|
|
290
|
150
|
// YOUR CODE HERE
|
|
151
|
+ return "Este el mensaje cuando aun no has implementado la funcion";
|
291
|
152
|
|
292
|
153
|
}
|