Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <fstream>
- #include <string>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- //Объявляем массив символов русского и английского алфавита
- string alpha = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя,-.";
- int code(char str)
- {
- for (int i = 0; i < 33; i++) {
- if (str == alpha[i])
- return i;
- }
- }
- unsigned short lfsr = 0xACE1u;
- unsigned bit;
- unsigned period = 0;
- int main() {
- system("chcp 1251");
- system("cls");
- setlocale(LC_ALL, "Russian");
- ifstream start("start.txt");
- ofstream output("out.txt");
- char alphaB[30][2] = { ' ' };
- string message;
- int keym[10];
- string keybuf;
- string key;
- getline(start, key);
- getline(start, message);
- cout << endl;
- int o;
- int ukazi = 0;
- int ukazj = 0;
- int A = 43;
- int C = 6;
- keym[0] = code(key[0]);
- for (int i = 1; i < 10; ++i)
- {
- int buf;
- buf = (A*keym[i - 1] + C) % 33;
- keym[i] = buf % 33;
- }
- string decode;
- for (int i = 0; i < message.length(); ++i) {
- char buf = (message[i] ^ keym[i % 10]);
- output << buf << ' ';
- decode += buf;
- }
- cout << endl << decode << endl;
- for (int i = 0; i < decode.length(); ++i) {
- char buf = (decode[i] ^ keym[i % 10]);
- cout << buf;
- }
- cout << endl;
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment