program vieg;

{$APPTYPE CONSOLE}

uses
  SysUtils, Classes;


//tato funkce projede vsechny moznosti a vrati vsechny mozne klice
//(je jich stejne, jako pismen v crypted textu)
function Encrypt(plain,key:string):string;
var i,j:Integer;
    str:string;
    posun:shortint;
begin
 Result := '';

 plain := LowerCase(plain);
 key   := LowerCase(key);

 for i := 1 to Length(plain) do
  begin
   posun := key[i mod Length(key)]-97;

   if (ord(plain)+posun > 122) then
     Result := Result + chr(ord(plain)+posun-26) else Result := Result + chr(ord(plain)+posun);
  end;//for i

end;//function

var
 key,plain:string;
 i:Integer;
 ret:TStrings;
begin
  try
    writeln('-- Sifrovator Viegenrovy sifry --');
    writeln('Zadejte klic:');
    readln(key);
    writeln('Zadejte plaintext:');
    readln(plain);

    writeln('Vysledek:');
    writeln(Encrypt(plain,key));
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.

