CCCPaste
private static void Main(string[] args)
{
// Szyfr cezara
// 4 -klucz
// abcdefghijklmnopqrstuvwxyz - alfabet
// ada - tekst do zakodowania
// eie - zakodowany tekst

System.Console.WriteLine("Podaj tekst do zakodowania:");
string haslo = Console.ReadLine();
System.Console.WriteLine("Podaj klucz kodowania:");
int klucz = int.Parse(Console.ReadLine());

string zakodowana = Zakoduj(haslo, klucz);

System.Console.WriteLine(zakodowana);
}


private static string Zakoduj(string haslo, int klucz)
{
string zakodowana ="";
const string alfabet = "abcdefghijklmnopqrstuvwxyz";
int znaki = alfabet.Length;

for (int i = 0; i < haslo.Length; i++)
{
if (alfabet.Contains(haslo[i]))
{
int znakAlfabetu = (i + klucz) % alfabet.Length;
zakodowana += alfabet[znakAlfabetu];
}
else
{
zakodowana+= haslo[i];
}
}
return zakodowana;
}