Input
Only alphabetical string is acceptable.
String length can range from 1 to 10.
Decrypt
Only alphabetical string is acceptable.
String length can range from 1 to 10.
118 | ASCII value of Character |
#include<stdio.h> |
#include<string.h> |
char output_str[20]; |
char *enc_dec(char *text,char key); |
void main(){ |
char input_str[20],*enc_str,*dec_str,enc_key; |
printf("\nEnter String\n"); |
gets(input_str); |
printf("\nEnter Encryption Key\n"); |
scanf("%c",&enc_key); |
getchar(); |
enc_str=enc_dec(input_str,enc_key); |
printf("\n%s\n",enc_str); |
printf("\nEnter String\n"); |
gets(input_str); |
printf("\nEnter Decryption Key\n"); |
scanf("%c",&enc_key); |
dec_str=enc_dec(input_str,enc_key); |
printf("\n%s\n",dec_str); |
} |
char *enc_dec(char *text,char key){ |
int i; |
for (i = 0; i < strlen(text); i++) |
output_str[i]=text[i]^key; |
return (char *)output_str; |
} |