Suppose you want to send a message to your friend but don’t want others to understand that message.
So, you have decided to encrypt the message.
Now, suppose the message is in a string variable called MSG. a) You have to encrypt the message and
change the string so that others cannot understand it. b) Again, decrypt the encrypted message.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
void shifr(char *s)
{
for(int i=0;i<strlen(s);i++)
{
s[i]=(char)(int(s[i])+8);
}
}
void deshifr(char *s)
{
for(int i=0;i<strlen(s);i++)
{
s[i]=(char)(int(s[i])-8);
}
}
int main() {
char s[125]="Hello";
shifr(s);
printf("%s\n",s);
deshifr(s);
printf("%s\n",s);
return 0;
}
Comments
Leave a comment