Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Project.doc
Скачиваний:
1
Добавлен:
02.05.2019
Размер:
319.49 Кб
Скачать

Висновки

У роботі розглянуто питання шифрування зображення на основі їх власне графічної складової (тобто не як файлу на жорсткому диску, а як картинки на екрані комп’ютера) та ознайомлення з основними принципами та методами шифрування.

Основні результати, отримані при виконанні наукової роботи наступні:

  • розроблено 2 програми: перша – зашифровує файли, а друга – їх розшифровує;

  • для програм розроблено достатньо простий, але досить потужний алгоритм шифрування;

  • тестування програми показало, що шифрування і розшифрування 8-бітних зображень відбувається дещо повільніше, ніж ті ж дії над зображеннями з іншою кількістю кольорів. Виявилось, що це недолік бібліотеки EasyBMP, але автор бібліотеки пообіцяв виправити дану ситуацію.

Список літератури

  1. Керниган Б. У., Ритчи Д. М. «Язык программирования C»

  2. Страуструп Б. «Язык программирования C++»

  3. Шилдт Г. «C++ для начинающих: Шаг за шагом»

  4. Шилдт Г. «Полный справочник по C++»

Список сайтів

  1. http://ru.wikipedia.org/wiki/Заглавная_страница

  2. http://jenyay.net

Плани щодо майбутнього програми

У найближчому майбутньому планується зробити такий собі TODO-список, до якого будуть заноситись всі ідеї, які потім будуть сортуватись у порядку важливості.

Але і зараз вже є деякі ідеї:

  • Реалізувати для обох програм єдиний графічний інтерфейс і єдиний виконавчий файл. Скоріше всього цей інтерфейс буде побудований на Qt – фреймворку, що зараз розвивається досить швидкими темпами, має гарну документацію та відкритий вихідний код. Можливо програма буде переписана на C# або Java, але це навряд чи.

  • Зробити шифрування за паролем, який буде генеруватись на основі самого зображення та технології зчитування цього пароля з зашифрованого зображення для його розшифрування.

  • Зробити шифрування за паролем, який введе користувач.

  • Шифрування не тільки BMP-зображень шляхом впровадження іншої бібліотеки для роботи з зображеннями (наприклад, ImageMagick/GraphicsMagick) або створення своєї власної бібліотеки для роботи з зображеннями на основі інших бібліотек.

  • Винесення коду, що відповідає за шифрування у окремі функції (зараз це не реалізовано через складнощі роботи з двомірними масивами) і винесення цих функцій у окрему бібліотеку.

Власне цей список буде доповнюватись, уточнюватись і розширятись.

Додаток а. Текст програми

#include "EasyBMP.h"

#include <iostream>

#include <fstream>

#include <cstdio>

#define SQUARE_SIZE 10

using namespace std;

int main(int argc, char* argv[])

{

BMP Input, Output;

char input_path[80

output_path[80];

do {

if (argc != 3) {

cout << "Put the name of the original file (for input):\n";

cin >> input_path;

}

else if (argc == 3) {

for (int i = 0; i < strlen(argv[1]); i++)

input_path[i] = argv[1][i];

input_path[strlen(argv[1])] = '\0';

}

}

while (Input.ReadFromFile(input_path) != 1);

if (argc != 3) {

cout << "Put the name of the encoded file (for output):\n";

cin >> output_path;

}

else if (argc == 3){

for (int i = 0; i < strlen(argv[2]); i++)

output_path[i] = argv[2][i];

output_path[strlen(argv[2])] = '\0';

}

register int Width = (int)Input.TellWidth(),

Height = (int)Input.TellHeight(),

BitDepth = (int)Input.TellBitDepth();

cout << "File info:" << endl;

cout << Width << " x " << Height

<< " at " << BitDepth << " bpp" << endl;

Output.SetBitDepth(BitDepth);

Output.SetSize(Width, Height);

RGBApixel Temp;

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++) {

Temp = Input.GetPixel(w, h);

Output.SetPixel(w, h, Temp);

}

RGBApixel pixels[Height][Width];

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++)

pixels[h][w] = Input.GetPixel(w, h);

const int h_const = (Height - Height % SQUARE_SIZE) / 2 - ((Height - Height % SQUARE_SIZE) / 2) % SQUARE_SIZE;

const int w_const = (Width - Width % SQUARE_SIZE) / 2 - ((Width - Width % SQUARE_SIZE) / 2) % SQUARE_SIZE;

for (int h = 0; h < h_const; h += SQUARE_SIZE)

for (int w = 0; w < Width - Width % SQUARE_SIZE - SQUARE_SIZE; w += SQUARE_SIZE * 2)

for (int p_h = 0; p_h < SQUARE_SIZE; p_h++)

for (int p_w = 0; p_w < SQUARE_SIZE; p_w++)

{

Temp = pixels[h + p_h][w + p_w];

pixels[h + p_h][w + p_w] = pixels[Height - Height % SQUARE_SIZE - SQUARE_SIZE - h + p_h][w + p_w];

pixels[Height - Height % SQUARE_SIZE - SQUARE_SIZE - h + p_h][w + p_w] = Temp;

}

for (int h = 0; h < Height - Height % SQUARE_SIZE - SQUARE_SIZE; h += SQUARE_SIZE * 2)

for (int w = 0; w < w_const; w += SQUARE_SIZE)

for (int p_h = 0; p_h < SQUARE_SIZE; p_h++)

for (int p_w = 0; p_w < SQUARE_SIZE; p_w++) {

Temp = pixels[h + p_h][w + p_w];

pixels[h + p_h][w + p_w] = pixels[h + p_h][Width - Width % SQUARE_SIZE - SQUARE_SIZE - w + p_w];

pixels[h + p_h][Width - Width % SQUARE_SIZE - SQUARE_SIZE - w + p_w] = Temp;

}

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++)

Output.SetPixel(w, h, pixels[h][w]);

fstream out(output_path);

out.close();

Output.WriteToFile(output_path);

cout << "If you haven't seen the error messsage then file (" << input_path << ") was succesfully encoded to another file (" << output_path << ")! :)" << endl;

getchar();

return 0;

}

bmp_encode.cpp (програма для шифровування):

#include "EasyBMP.h"

#include <iostream>

#include <fstream>

#include <cstdio>

#define SQUARE_SIZE 10

using namespace std;

int main(int argc, char* argv[])

{

BMP Input, Output;

char input_path[80

output_path[80];

do {

if (argc != 3) {

cout << "Put the name of the encoded file (for input):\n";

cin >> input_path;

}

else if (argc == 3) {

for (int i = 0; i < strlen(argv[1]); i++)

input_path[i] = argv[1][i];

input_path[strlen(argv[1])] = '\0';

}

}

while (Input.ReadFromFile(input_path) != 1);

if (argc != 3) {

cout << "Put the name of the decoded file (for output):\n";

cin >> output_path;

}

else if (argc == 3){

for (int i = 0; i < strlen(argv[2]); i++)

output_path[i] = argv[2][i];

output_path[strlen(argv[2])] = '\0';

}

register int Width = (int)Input.TellWidth(),

Height = (int)Input.TellHeight(),

BitDepth = (int)Input.TellBitDepth();

cout << "File info:" << endl;

cout << Width << " x " << Height

<< " at " << BitDepth << " bpp" << endl;

Output.SetBitDepth(BitDepth);

Output.SetSize(Width, Height);

RGBApixel Temp;

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++) {

Temp = Input.GetPixel(w, h);

Output.SetPixel(w, h, Temp);

}

RGBApixel pixels[Height][Width];

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++)

pixels[h][w] = Input.GetPixel(w, h);

const int h_const = (Height - Height % SQUARE_SIZE) / 2 - ((Height - Height % SQUARE_SIZE) / 2) % SQUARE_SIZE;

const int w_const = (Width - Width % SQUARE_SIZE) / 2 - ((Width - Width % SQUARE_SIZE) / 2) % SQUARE_SIZE;

for (int h = 0; h < Height - Height % SQUARE_SIZE - SQUARE_SIZE; h += SQUARE_SIZE * 2)

for (int w = 0; w < w_const; w += SQUARE_SIZE)

for (int p_h = 0; p_h < SQUARE_SIZE; p_h++)

for (int p_w = 0; p_w < SQUARE_SIZE; p_w++) {

Temp = pixels[h + p_h][w + p_w];

pixels[h + p_h][w + p_w] = pixels[h + p_h][Width - Width % SQUARE_SIZE - SQUARE_SIZE - w + p_w];

pixels[h + p_h][Width - Width % SQUARE_SIZE - SQUARE_SIZE - w + p_w] = Temp;

}

for (int h = 0; h < h_const; h += SQUARE_SIZE)

for (int w = 0; w < Width - Width % SQUARE_SIZE - SQUARE_SIZE; w += SQUARE_SIZE * 2)

for (int p_h = 0; p_h < SQUARE_SIZE; p_h++)

for (int p_w = 0; p_w < SQUARE_SIZE; p_w++)

{

Temp = pixels[h + p_h][w + p_w];

pixels[h + p_h][w + p_w] = pixels[Height - Height % SQUARE_SIZE - SQUARE_SIZE - h + p_h][w + p_w];

pixels[Height - Height % SQUARE_SIZE - SQUARE_SIZE - h + p_h][w + p_w] = Temp;

}

for (int h = 0; h < Height; h++)

for (int w = 0; w < Width; w++)

Output.SetPixel(w, h, pixels[h][w]);

fstream out(output_path);

out.close();

Output.WriteToFile(output_path);

cout << "If you haven't seen the error messsage then file (" << input_path << ") was succesfully decoded to another file (" << output_path << ")! :)" << endl;

getchar();

return 0;

}

Весь вихідний код програми матеріал для програми знаходиться на диску у директорії Program\Sources, тут приведений лише код власне програми без коду бібліотек.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]