Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string szyfrowanie(string txt, string klucz)
- {
- for (int i = 0; i < txt.size(); i++)
- {
- int znakTekst = txt[i] - 'A';
- int znakKlucz = klucz[i % klucz.length()] - 'A';
- txt[i] = (char)((znakTekst ^ znakKlucz) + 'A');
- }
- return txt;
- }
- int main()
- {
- string txt, klucz;
- cout << "Podaj klucz (od B do Z): ";
- cin >> klucz;
- cout << "Podaj tekst jawny: ";
- cin >> txt;
- cout << "Szyfrogram to: ";
- cout << szyfrowanie(txt, klucz)<<endl;
- cout << "Po rozszyfrowaniu: ";
- cout << szyfrowanie(szyfrowanie(txt, klucz), klucz);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement