Академический Документы
Профессиональный Документы
Культура Документы
FUNDAMENTALS
Devang Pirta
Affine Cipher
Program:
#include <iostream>
#include <cstdio> using
namespace std;
cout << "\nEnter 0 for Encrypt and 1 for Decrypt: " << endl; cin >>
choice;
switch(choice){ case 0: cout <<
encrypt(alpha, beta, text) << endl; break; case
1: cout << decrypt(alpha, beta, text) << endl;
break; default:
cout << "Wrong choice" << endl;
}}
Sample runs:
Problem :
To implement Hill Cipher technique.
Hill Cipher
Program:
#include<iostream>
#include<math.h>
using namespace std;
cout<<"\n";
} void
getKeyMessage() {
int i, j; char msg[3];
cout << "Enter a 3 letter string: " << endl; cin
>> msg; for(i = 0; i < 3; i++){ mes[i][0] =
msg[i] - 97;
}
cout << "Enter 3x3 invertible key matrix: " << endl;
for(i = 0; i < 3; i++){ for(j = 0; j < 3; j++){
scanf("%f", &a[i][j]); c[i][j] = a[i][j];
}
}
} int main(){ int
choice;
getKeyMessage();
cout << "\nEnter 0 for Encrypt and 1 for Decrypt: " << endl; cin >>
choice;
switch(choice){
case 0:
encryption();
break; case 1:
decryption();
break; default:
cout << "Wrong choice" << endl;
}}
Sample runs: