Write a simple encryption program using string functions which apply the substitution method. Explain the program by parts. Here is the given substitution table:
Substitution table:
A = *
E = $
I = /
O = +
U = -
Sample:
Enter message: meet me now
Encrypted message: m$$t m$ n+w
I can make use of strings...strcpy,puts, gets, strlen, strcat, strlwr, strupr, strrev, strcmp, strcmpi?
Because it is impossible to tell without knowing the data in advance how many characters gets() will read, and because gets() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security.
Use fgets() instead
SORRY i dont really understand...my prof doesnt really teach...he gives us codes and examples and gives us these things and expects us to create something by our selves
bool vowel(char c){
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'|| c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')
return true;
return false;
}
char replace(char c)
{
switch(c)
{
case 'a': case 'A': return '*';
case 'e': case 'E': return '$';
case 'i': case 'I': return '/';
case 'o': case 'O': return '+';
case 'u': case 'U': return '-';
}
}
int main(int argc, char *argv[])
{
char input[100];
cout<<"Input phrase :";
gets(input);
for(int i=0; i <100; i++){
if(vowel(input[i]))
input[i]=replace(input[i]);
}