GamerSK

sifra + kluc

Feb 15th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. //START Sifrovanie
  2.     AnsiString kluc = InputBox("Zadajte váš klúč","klúč","");
  3.     if ( kluc == "" ) {
  4.         ShowMessage("Musite zadať kluc!!!!!!!!!");
  5.     } else {
  6.         AnsiString str = InputBox("Zadajte text, ktorý chcete zasifrovat","text","");
  7.         AnsiChar c;
  8.         int i = 1;
  9.         int j = 1;
  10.         if ( str == "" ) {
  11.             ShowMessage("Musite zadať text!!!!!!!!!");
  12.         } else {
  13.             ofstream f;
  14.             f.open("sifra-kluc.txt");
  15.             while ( i <= str.Length() ) {
  16.                 if ( kluc.Length() == i ) {
  17.                     j = 1;
  18.                 }
  19.                 c = str[i]+kluc[j];
  20.                 f.put(c);
  21.                 Label4->Caption=Label4->Caption + c;
  22.                 i++;
  23.                 j++;
  24.             }
  25.             f.close();
  26.         }
  27.     //END Sifrovanie
  28.     //START Získanie šifry
  29.         ifstream g;
  30.         g.open("sifra-kluc.txt");
  31.         AnsiString sifra;
  32.         if ( g.good() ) {
  33.             g.get(c);
  34.             while ( g.good() ) {
  35.                 sifra += c;
  36.                 g.get(c);
  37.             }
  38.         }
  39.         g.close();
  40.     //END Získanie šifry
  41.     //START Desifrovanie
  42.         ofstream l;
  43.         l.open("desifra-kluc.txt");
  44.         i = 1;
  45.         j = 1;
  46.         while ( i <= sifra.Length() ) {
  47.             if ( kluc.Length() == i ) {
  48.                 j = 1;
  49.             }
  50.             c = sifra[i]-kluc[j];
  51.             l.put(c);
  52.             Label5->Caption=Label5->Caption + c;
  53.             i++;
  54.             j++;
  55.         }
  56.         l.close();
  57.  
  58.     }
  59.     //END Desifrovanie
Advertisement
Add Comment
Please, Sign In to add comment