Защита Информации / зи лб 2
.docxМИНИСТЕРСТВО ОБРАЗОВАНИЯ и НАУКИ
КЫРГЫЗСКОЙ РЕСПУБЛИКИ
КЫРГЫЗСКИЙ ГОСУДАРСТВЕННЫЙ ТЕХНИЧЕСКИЙ УНИВЕРСИТЕТ им. И. РАЗЗАКОВА
ФАКУЛЬТЕТ ИНФОРМАЦИОННЫХ ТЕХНОЛОГИЙ
КАФЕДРА «ИНФОРМАТИКА И ВЫЧИСЛИТЕЛЬНАЯ ТЕХНИКА»
Отчет
По защите информации
Лабораторная работа 2
Бишкек 2019
Шифр Порта
#include<iostream>
#include<string>
using namespace std;
int main() {
setlocale(0, "");
int number = 1010, MP[38][38], ST[333];
int ind1, ind2, index = 0;
string alf = "абвгдежзийклмнопрстуфхцчшщъыьэюя,.!?- ",
txt = "куда то в даль убегают года чему себя ты отдал", RT[333];
for (int i = 0; i < alf.length(); i++) {
cout << " " << alf[i];
}
cout << endl;
for (int i = 0; i < alf.length(); i++) {
cout << alf[i] << " ";
for (int j = 0; j < alf.length(); j++) {
MP[i][j] = number;
number++;
cout << MP[i][j] << " ";
}
cout << endl;
}
cout << endl;
int l = txt.length();
if (l % 2 == 1) {
txt[l] = ' ';
}
cout << "Шифрованный текст: ";
for (int i = 0; i < txt.length(); i += 2) {
for (int j = 0; j < alf.length(); j++) {
if (txt[i] == alf[j]) ind1 = j;
if (txt[i + 1] == alf[j]) ind2 = j;
}
ST[i] = MP[ind1][ind2];
cout << ST[i];
}
cout << endl;
cout << "Расшифрованный текст: ";
for (int i = 0; i < txt.length(); i++) {
for (int j = 0; j < alf.length(); j++) {
for (int k = 0; k < alf.length(); k++) {
if (ST[i] == MP[j][k]) {
RT[index] = alf[j];
RT[index + 1] = alf[k];
}
}
}
cout << RT[index] << RT[index + 1];
index += 2;
}
cout << endl;
system("pause");
}