#include
|
|
|
#include
|
|
#include
|
|
#include
|
|
using namespace std;
|
|
// Øèôðîâàíèå
|
|
string encrypt(string input) {
|
|
vector word(input.begin(), input.end());
|
|
string alphabet = "abcdefghijklmnopqrstuvwxyz";
|
|
for (int i = 0; i < (int)input.length(); i++) {
|
|
for (int j = 0; j < (int)alphabet.length(); j++) {
|
|
if (word[i] == alphabet[j]) {
|
|
word[i] = alphabet[(j + 3) % 26];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
string str(word.begin(), word.end());
|
|
return str;
|
|
}
|
|
// Ðàñøèôðîâêà
|
|
string decrypt(string input) {
|
|
vector word(input.begin(), input.end());
|
|
string alphabet = "abcdefghijklmnopqrstuvwxyz";
|
|
for (int i = 0; i < (int)input.length(); i++) {
|
|
for (int j = 0; j < (int)alphabet.length(); j++) {
|
|
if (word[i] == alphabet[j]) {
|
|
word[i] = alphabet[(j - 3) % 26];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
string str(word.begin(), word.end());
|
|
return str;
|
|
}
|
|
int main() {
|
|
// Îáû÷íûé âèä áåç øèôðîâàíèÿ
|
|
string text = "What are u doing dude?";
|
|
cout << text << endl;
|
|
// Øèôðîâàíèå ññûëêè
|
|
string url = encrypt("https://yandex.ru/");
|
|
cout << url << endl;
|
|
// Øèôðîâààíèå òåêñòà
|
|
string textencrypt = encrypt(text);
|
|
cout << textencrypt << endl;
|
|
// Ðàñøèôðîâêà çàøèôðîâàííîãî òåêñòà
|
|
string textdecrypt = decrypt(textencrypt);
|
|
cout << textdecrypt << endl;
|
|
_getch();
|
|
return 0;
|
|
}
|