Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. string wejscie,klucz;
  2.             int j=0;
  3.             unsigned n,x,c,poz=0,wynik=1;
  4.  
  5.             key>>klucz;
  6.             input>>wejscie;
  7.             const char* buf = wejscie.c_str();
  8.             if(flaga_algorytmu==false)
  9.             {
  10.                 x=(int)strtoul(klucz.substr(0,2).c_str(),NULL,16);
  11.             }
  12.             else
  13.             {
  14.                 x=(int)strtoul(klucz.substr(0,2).c_str(),NULL,16);
  15.             }
  16.             n=(int)strtoul(klucz.substr(klucz.find(";")+1,2).c_str(),NULL,16);
  17.             while(poz<wejscie.length())
  18.             {
  19.                 wynik=1;
  20.                 c = (int)wejscie[poz];
  21.                 poz++;
  22.                 if(flaga_algorytmu==false)
  23.                 {
  24.                     c%=n;
  25.                     for(int i=0; i<x; i++)
  26.                     {
  27.                         wynik *= c;
  28.                         wynik %= n;
  29.                     }
  30.                     output << (char)wynik;
  31.  
  32.                 }
  33.                 else
  34.                 {
  35.                     c%=n;
  36.                     for(int i=0; i<x; i++)
  37.                     {
  38.                         wynik *= c;
  39.                         wynik %= n;
  40.                     }
  41.                     output << (char)wynik;
  42.                 }
  43.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement