#include #include
Download 1.3 Mb.
|
Kiberxavfsizlik 2,3,4
Kiberxavfsizlik asoslari fanidan Mamadjonov Muhammadalining 2-amaliy ishi O`rin almashtirish, 1 ta kalit yordamida va 2 ta kalit yordamida o`rin almashtirib shifrlash kodi : #include #include #include #include using namespace std; bool axonalison(int a, int son){ string son_s = to_string(son); if(a == son_s.length()){ return true; } else{ return false; } } void matn_show(string s){ cout << "Matn uzunligini kiritasizmi : "; string hayoq; cin.ignore(); getline(cin, hayoq); if(hayoq == "ha" || hayoq == "Ha" || hayoq == "xa" || hayoq == "Xa"){ cout << "Yaxshi, matn nechta belgidan iborat ekanligini kiriting : "; int soni; cin >> soni; cout << "Sizning matningiz : "; for(int i = 0; i < soni; i++){ cout << s[i]; } } else{ cout << "Sizning matningiz : " << s << endl; } } int main(){ int qwerty; cout << "Shifrlash --> 1\nDeshifrlash --> 2\n------> "; cin >> qwerty; cin.ignore(); switch(qwerty){ case 1:{ string s; cout << "Matnni kiriting : "; getline(cin, s); cout << s.length() << " ta belgidan iborat so`z kiritdingiz !!!\n"; srand(time(0)); if(s != ""){ int a; if(sqrt(s.length()) > (int)sqrt(s.length())){ a = (int)sqrt(s.length()) + 1; for(int i = s.length(); i < a*a; i++){ char charr = (char) (rand() % 89 + 33); s += charr; } }else{ a = sqrt(s.length()); } char arr[a][a]; int q = 0; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ arr[i][j] = s[q]; q++; } } for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << arr[i][j] << ' '; } cout << endl; } cout << "Qanday usulda : \nOddiy --> 1\nBir kalit bilan --> 2\nIkki kalit bilan --> 3\n------> "; int n; cin >> n; switch(n){ case 1:{ cout << "O`zgartirish : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << arr[j][i] << " "; } cout << endl; } cout << "Natija : "; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << arr[j][i]; } } break; } case 2:{ int kalit; char mas[a][a]; cout << "Iltimos " << a << " xonali son kiriting : "; cin >> kalit; while(axonalison(a, kalit) == false){ cout << "Iltimos " << a << " xonali son kiriting : "; cin >> kalit; } string kalit_s = to_string(kalit); int kalit_ar[kalit_s.length()]; for(int i = 0; i < a; i++){ cout << kalit_s[i] << " "; kalit_ar[i] = (int)(kalit_s[i] - '0'); } cout << endl; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ mas[i][j] = arr[j][i]; cout << mas[i][j] << " "; } cout << endl; } cout << "Kalit bo`yicha o`zgartirish : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a - i - 1; j++){ if(kalit_ar[j] > kalit_ar[j+1]){ swap(kalit_ar[j], kalit_ar[j+1]); for(int we = 0; we < a; we++){ swap(mas[we][j], mas[we][j+1]); } } } } for(int i = 0; i < a; i++){ cout << kalit_ar[i] << " "; } cout << endl; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << mas[i][j] << ' '; } cout << endl; } cout << "Natija : "; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << mas[i][j]; } } break; } case 3:{ int kalit1, kalit2; int kalit1_ar[a]; cout << "1 - kalit --> Iltimos " << a << " xonali son kiriting : "; cin >> kalit1; while(axonalison(a, kalit1) == false){ cout << "Iltimos " << a << " xonali son kiriting : "; cin >> kalit1; } string kalit1_s = to_string(kalit1); for(int i = 0; i < a; i++){ cout << kalit1_s[i] << " "; kalit1_ar[i] = (int)(kalit1_s[i] - '0'); } cout << endl << endl; char mas[a][a]; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ mas[i][j] = arr[j][i]; cout << mas[i][j] << ' '; } cout << endl; } cout << "1 - kalit bo`yicha terish : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a - i - 1; j++){ if(kalit1_ar[j] > kalit1_ar[j+1]){ swap(kalit1_ar[j], kalit1_ar[j+1]); for(int we = 0; we < a; we++){ swap(mas[we][j], mas[we][j+1]); } } } } for(int i = 0; i < a; i++){ cout << kalit1_ar[i] << " "; } cout << endl << endl; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << mas[i][j] << ' '; } cout << endl; } cout << "Yaxshi, 2 - kalit --> Iltimos " << a << " xonali son kiriting : "; cin >> kalit2; while(axonalison(a, kalit2) == false){ cout << "Iltimos " << a << " xonali son kiriting : "; cin >> kalit2; } string kalit2_s = to_string(kalit2); int kalit2_ar[a]; for(int i = 0; i < a; i++){ kalit2_ar[i] = (kalit2_s[i] - '0'); } for(int i = 0; i < a; i++){ cout << kalit2_ar[i] << " "; for(int j = 0; j < a; j++){ cout << mas[i][j] << ' '; } cout << endl; } cout << "2 - kalit bo`yicha terish : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a - i - 1; j++){ if(kalit2_ar[j] > kalit2_ar[j+1]){ swap(kalit2_ar[j], kalit2_ar[j+1]); for(int ws = 0; ws < a; ws++){ swap(mas[j][ws], mas[j+1][ws]); } } } } for(int i = 0; i < a; i++){ cout << kalit2_ar[i] << " "; for(int j = 0; j < a; j++){ cout << mas[i][j] << ' '; } cout << endl; } cout << "\nNatija : "; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << mas[i][j]; } } break; } default:{ cout << "ERROR"; break; } } } else{ cout << "Matn bo`sh bo`lishi mumkin emas!"; } break; } case 2:{ string s; cout << "Matnni kiriting : "; getline(cin, s); int a = sqrt(s.length()); char q[a][a]; int p = 0; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ q[i][j] = s[p]; p++; } } cout << "Jadvaldagi ko`rinishi : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << q[i][j] << ' '; } cout << endl; } cout << "Qanday usulda : \nOddiy --> 1\nBir kalit bilan --> 2\nIkki kalit bilan --> 3\n------> "; int n; cin >> n; switch(n){ case 1:{ string matn = ""; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ matn += q[j][i]; } } cout << "Qaytarilgandan so`ng : \n"; for(int i = 0; i < a; i++){ for(int j = 0; j < a; j++){ cout << q[j][i] << " "; } cout << endl; } matn_show(matn); break; } case 2 :{ //---// break; } case 3 :{ //---// break; } default :{ cout << "ERROR"; break; } } break; } default :{ cout << "ERROR"; break; } } } 1.O`rin almashtirish : 2.1 kalit bilan : 3.2 kalit bilan : Izoh : Dasturda deshifrlash ham keltirilgan. Lekin faqat oddiy usulni deshifrlay oladi : 4.Verjam shifrlash usuli 5.Vijiner shifrlash usuli : 6.Sezar shifrlash usuli : 3-Amaliy ish Mavzu: TrueCrypt yordamida ma'lumotlarni shifrlashni o'rganish. TrueCrypt -ni http://www.truecrypt.org/downloads dasturni o`rnatamiz. O`rnatib oldik Disk nomini tanlab create valume ni tanlemiz va next davom etamiz. Fayl joylashgan manzilini tanlaymiz. Fayl hajmiga nisbatan kattaroq hajmni belgilaymiz.. va next bosamiz Diskka password kiritamiz. Qiymat yaratildi. “Мой компьютер”-ni ochsangiz, u yerda shifrlangan hajmingizni ifodalovchi yangi diskni ko'rasiz. 4-amaliy ish 1 – usul : 1.cmd ga administrator nomi bilan kiramiz, Muhammadali1 nomi bilan yangi foydalanuvchi yaratamiz. 2.Barcha foydalanuvchilarni ko`rish uchun net user buyrug`idan foydalanamiz : 3.Yaratilgan foydalanuvchiga parol qo`yamiz : 4.Bu userni o`chirish : 2-usul : Sozlamalarga kiramiz : 2.Foydalanuvchi nomi va parolni ushbu oynada kiritamiz : Va next tugmasi bosiladi. Download 1.3 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling