Beruflich Dokumente
Kultur Dokumente
DISCRETE ASSINGMENT
Types Of Cryptography:
As manually encryption and decryption of any type of cryptography takes time that’s why to
solve that problem and make you able to complete your work faster I have made programs in
each type. From these programs you have only to type your message which you want to encrypt
or decrypt.
Ceaser’s Cipher:
It is one of the simplest encryption technique in which each character in plain text is replaced by
a character some fixed number of positions down to it. For example, if key is 3 then we have to
replace character by another character that is 3 position down to it. Like A will be replaced by D,
C will be replaced by F and so on.
Ceaser Cipher Encryption :
Code :
#include<iostream>
using namespace std;
int main()
{
char message[100], ch;
int i, key;
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + key;
message[i] = ch;
}
}
Code:
#include<iostream>
using namespace std;
int main()
{
char message[100], ch;
int i, key;
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch - key;
message[i] = ch;
}
}
Affine Cipher :
Introduction:
The Affine cipher is a special case of the more general monoalphabetic substitution cipher.
The cipher is less secure than a substitution cipher as it is vulnerable to all of the attacks that
work against substitution ciphers, in addition to other attacks.
The 'key' for the Affine cipher consists of 2 numbers, we'll call them a and b. The following
discussion assumes the use of a 26 character alphabet (m = 26). a should be chosen to be
relatively prime to m (i.e. a should have no factors in common with m).
CODE:
#include<iostream>
INTRODUCTION:
RSA encryption is a public-key encryption technology developed by RSA Data Security. The
RSA algorithm is based on the difficulty in factoring very large numbers. Based on this
principle, the RSA encryption algorithm uses prime factorization as the trap door for
encryption. Deducing an RSA key, therefore, takes a huge amount of time and processing
power. RSA is the standard encryption method for important data, especially data that's
transmitted over the Internet.
RSA stands for the creators of the technique, Rivest, Shamir and Adelman.
CODE:
#include <iostream>
using namespace std;
int main()
{
int i, x;
char str[100];
cout << "\nYOUR MESSAGE AFTER INCRPTION : " << str << endl;
break;
case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - 2;
cout << "\nYOUR MESSAGE AFTER DECRYPTION : " <<str << endl;
break;
default:
cout << "\nINVALID INPUT !!!\n";
}
return 0;
}