Mavzu: Ochiq kalitli shifrlash algoritmlari dasturiy modulini ishlab chiqish. Ishdan maqsad



Download 58.53 Kb.
Sana09.10.2019
Hajmi58.53 Kb.
1-Labaratoriya ishi

Mavzu: Ochiq kalitli shifrlash algoritmlari dasturiy modulini ishlab chiqish.

Ishdan maqsad: Asimmetrik shifrlash algoritmlaridan amalda foydalanish ko’nikmalariga ega bo’lish.

Amaliy qism

1-rasm.El-Gamal algoritmida shifrlash.

Ochiq habar: MUHAMMADJONOV

Kalit: ASCII qiymat+3



Shifrmatn:OWJCOOCFLQPQX

2-rasm.El-Gamal algoritmida deshifrlash

Shifrmatn:OWJCOOCFLQPQX

Kalit: ASCII qiymat+3

Ochiq habar: MUHAMMADJONOV

Ilova uchun dastur kodi



#include

using namespace std;

int main()

{

int i, x;



char str[100];

cout << "Please enter a string:\t";

cin >> str;

cout << "\nPlease choose following options:\n";

cout << "1 = Encrypt the string.\n";

cout << "2 = Decrypt the string.\n";

cin >> x;

//using switch case statements

switch(x)

{

//first case for encrypting a string



case 1:

for(i = 0; (i < 100 && str[i] != '\0'); i++)

str[i] = str[i] + 2; //the key for encryption is 3 that is added to ASCII value

cout << "\nEncrypted string: " << str << endl;

break;

//second case for decrypting a string



case 2:

for(i = 0; (i < 100 && str[i] != '\0'); i++)

str[i] = str[i] - 2; //the key for encryption is 3 that is subtracted to ASCII value
cout << "\nDecrypted string: " << str << endl;

break;


default:

cout << "\nInvalid Input !!!\n";



}

return 0;



}


Do'stlaringiz bilan baham:


Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2019
ma'muriyatiga murojaat qiling

    Bosh sahifa