I am trying to build an encryption/decryption program for fun. I know it won't be strong, I know people would crack it in seconds but I don't care. This is just to get to grips with it. I have code that works with the XOR encryption method. It needs a bit of work but its operating and that was my goal. What I want to do is design a very simple algorithm to replace XOR in my code. I assume that I should write a function and replacewith my algorithm e.g.Code:c^=*(key++);Can someone tell me how I might write a function to say increment every letter by 5, i.e. a = (a+5), b = (b+5), etc?Code:c = algo(c, *key++);
I should know this but I'm blanking!
Code so far:
Code:#include <stdio.h> int main(int argc, char*argv[]) { FILE *fp1, *fp2; char* key; int c; key = argv[1]; if(*key != '\0') { fp1 = fopen(argv[2],"rb"); if(fp1 != NULL) { fp2 = fopen(argv[3],"wb"); if (fp2 != NULL) { while((c=getc(fp1))!=EOF) { if(!*key)key = argv[1]; c ^=*(key++); putc(c, fp2); } fclose(fp2); } fclose(fp1); } } return 0; }



LinkBack URL
About LinkBacks



