Professional Documents
Culture Documents
Лабораторна робота №3
Лабораторна робота №3
Лабораторна робота № 3
з дисципліни “Криптографічні системи захисту інформації ”
Київ 2020
Тема: Ознайомлення з методом шифрування даних «Шифр Віженера».
Теоритичні відомості
Поліалфавітні підстановки маскують справжню частоту появи символів у шифрі, тому
вони значно надійніші як моно алфавітні. Однак, метод частотного аналізу можна
застосувати і для них. Шифр Віженера – полі алфавітна підстановка із використанням
одного алфавіту (кожна буква визначає свій алфавіт шифрування). Також цю
криптосистему можна розглядати як шифр гамування із використанням періодичної
гами малого періоду.
Хід роботи
string[] abc = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
string phrase = "";
string key1 = "";
string endcodephrase = "";
switch(check)
{
case "enc":
Console.Write("Enter phrase for Encrypt: ");
phrase = Console.ReadLine();
Console.Write("Enter key word: ");
key1 = Console.ReadLine();
CheckKey(key1);
endcodephrase = Encrypt(phrase, key1);
Console.WriteLine(endcodephrase);
break;
case "dec":
Console.Write("Enter phrase for Decrypt: ");
phrase = Console.ReadLine();
Console.Write("Enter key word: ");
key1 = Console.ReadLine();
CheckKey(key1);
endcodephrase = Decrypt(phrase, key1);
Console.WriteLine(endcodephrase);
break;
}
}
if (check2 == key.Length)
{
Console.WriteLine("Key is good!");
}
else
{
Console.WriteLine("Key isn`t correct, try again!");
Console.WriteLine("Enter key word: ");
key1 = Console.ReadLine();
CheckKey(key1);
}
}
if(pos >= 0)
{
if (j >= key.Length - 1)
{
string a = Convert.ToString(charkey[j]);
//Console.WriteLine("string a = " + a);
inkey = Array.IndexOf(abc, a);
j = 0;
}
else
{
string a = Convert.ToString(charkey[j]);
//Console.WriteLine("string a = " + a);
inkey = Array.IndexOf(abc, a);
j++;
}
Console.WriteLine("inkey: " + inkey);
if (pos >= 0)
{
if (j >= key.Length - 1)
{
string a = Convert.ToString(charkey[j]);
//Console.WriteLine("string a = " + a);
inkey = Array.IndexOf(abc, a);
j = 0;
}
else
{
string a = Convert.ToString(charkey[j]);
//Console.WriteLine("string a = " + a);
inkey = Array.IndexOf(abc, a);
j++;
}
Console.WriteLine("inkey: " + inkey);