Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // main.cpp
- // программа для сокрытия данных
- #include <iostream>
- #include <locale>
- #include <cstdlib>
- using namespace std;
- void data_code(); // прототип функции для фишрования
- //void data_encode(); // прототип фкнкции для дешифрования
- class work
- {
- public:
- void display_menu()
- {
- system("clear");
- cout << endl;
- cout << " Выберите действие : " << endl;
- cout << " Зашифровать данные: 1" << endl;
- cout << " Дешифровать данные: 2" << endl;
- cout << " Выход : 0" << endl;
- cout << endl;
- }
- void wat_do()
- {
- cout << " Что делать: ";
- cin >> process_id;
- }
- void triger()
- {
- if( process_id == 0 )
- exit(0);
- else if( process_id == 1 )
- {
- data_code();
- } else if( process_id == 2 )
- {
- ;
- // data_encode();
- } else {
- cout << " Ошибка, не верное значение!!!" << endl;
- cin.get(); cin.get();
- }
- }
- private:
- int process_id;
- };
- int main()
- {
- // inic
- work working;
- setlocale(LC_ALL,"Russian");
- // ïîâòîðÿòü
- while(1)
- {
- working.display_menu();
- working.wat_do();
- working.triger();
- }
- // end
- return 0;
- }
- void data_code()
- {
- // init
- int count_length = 0; // длина кода
- int data_cp; // копия кода
- int interation; // колво операций преобразования
- int data; // код
- int x1, x2, x3, x4; // цифры кода
- int y1, y2; // это
- // input interation
- system("clear");
- cout << "\n Введите кол-во интераций : ";
- cin >> interation;
- // if interation
- if( interation < 1 || interation > 80 )
- {
- cout << " Ошибка, не верное значение!!!" << endl;
- cout << "\n Введите кол-во интераций : ";
- cin >> interation;
- }
- // input data
- cout << " Введите информацию : ";
- cin >> data;
- // data length
- data_cp = data;
- while( data_cp != 0 )
- {
- data_cp/=10;
- ++count_length;
- }
- // if data
- while( count_length != 4 )
- {
- // input data code
- cout << " Ошибка, не верная длина!!!" << endl;
- cout << " Введите информацию : ";
- cin >> data;
- // data length
- data_cp = data;
- while( data_cp != 0 )
- {
- data_cp/=10;
- ++count_length;
- }
- }
- // lock data
- // get x
- x4 = data % 10;
- x3 = (data / 10) % 10;
- x2 = (data / 100 ) % 10;
- x1 = (data / 1000 ) % 10;
- // get y
- y2 = interation % 10;
- y1 = ( interation / 10 );
- // шифрование
- // преобразование
- for( int i = 1; i <= interation; i++ )
- {
- x1 = (x1 * 7) % 10;
- x2 = (x2 * 7) % 10;
- x3 = (x3 * 7) % 10;
- x4 = (x4 * 7) % 10;
- }
- // генерация ключа
- for( int i = 1; i <= 70; i++ )
- {
- y1 = ( y1 * 7 ) % 10;
- y2 = ( y2 * 7 ) % 10;
- }
- // Вывод
- cout << "\n Хеш : " << x3 << x4 << y2 << y1 << x1 << x2 << endl;
- cout << endl;
- cin.get(); cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement