- •Анотація
- •Криптографія та шифрування
- •Що таке криптографія?
- •Історія криптографії
- •Що таке шифрування?
- •Термінологія
- •Етапи шифрування
- •Види шифрування
- •Висновки
- •Розробка алгоритму программи шифрування
- •Ціль алгоритму
- •Створення алгоритму з врахуванням цілі
- •Суть роботи алгоритму
- •Фактична реалізація алгоритму
- •Висновки
- •Формат bmp. Опис та специфікація
- •Початкові відомості
- •Структура файлу
- •Складнощі у використанні
- •Висновки
- •Засоби реалізації алгоритму і программи
- •Обрання мови програмування
- •Обрання допоміжних засобів (бібліотек)
- •Висновки
- •Висновки
- •Список літератури
- •Список сайтів
- •Плани щодо майбутнього програми
- •Додаток а. Текст програми
- •Додаток б. Опис бібліотеки easybmp
- •Додаток в. Застосування програми на практиці
Висновки
У роботі розглянуто питання шифрування зображення на основі їх власне графічної складової (тобто не як файлу на жорсткому диску, а як картинки на екрані комп’ютера) та ознайомлення з основними принципами та методами шифрування.
Основні результати, отримані при виконанні наукової роботи наступні:
розроблено 2 програми: перша – зашифровує файли, а друга – їх розшифровує;
для програм розроблено достатньо простий, але досить потужний алгоритм шифрування;
тестування програми показало, що шифрування і розшифрування 8-бітних зображень відбувається дещо повільніше, ніж ті ж дії над зображеннями з іншою кількістю кольорів. Виявилось, що це недолік бібліотеки EasyBMP, але автор бібліотеки пообіцяв виправити дану ситуацію.
Список літератури
Керниган Б. У., Ритчи Д. М. «Язык программирования C»
Страуструп Б. «Язык программирования C++»
Шилдт Г. «C++ для начинающих: Шаг за шагом»
Шилдт Г. «Полный справочник по C++»
Список сайтів
http://ru.wikipedia.org/wiki/Заглавная_страница
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, тут приведений лише код власне програми без коду бібліотек.