/*Sinple Ex-Or encryption/decryption*/ #include void encr(char *src,char *dest,char *keyword); int main() { int len; char data,encrypted_text,decrypted_text,key; puts("Enter the length of the string: "); scanf("%d",&len); data=(char *)malloc(sizeof(len+1)); encrypted_text=(char *)malloc(len+1); decrypted_text=(char *)malloc(len+1); key=(char *)malloc(len+1); getchar();/*get character echoed*/ puts("Enter the data: "); fgets(data,len,stdin); puts("Enter the key (any string of characters): "); fgets(key,strlen(data),stdin); puts("Press Return to view results."); puts("Data: "); puts(data); encr(data,encrypted_text,key); puts("Encrypted text: "); puts(encrypted_text); encr(encrypted_text,decrypted_text,key); puts("Decrypted text: "); puts(decrypted_text); puts("Press Return to exit."); getchar(); } void encr(char *src,char *dest,char *keyword) { char *p,*q,*r; for(p=src,q=dest,r=keyword;*p!='\0';p++,q++,r++) { if(*r=='\0') r=keyword; *q=*p^*r; } *q='\0'; return; }