Hi all,
I am working on a encryption/decryption program that uses the auto key ciper method of encryption. Here is my encrypt func:
Here is my decrypt:Code:unsigned int encrypt(char x){ char a; if ( i == 0 ){ a = 'K';} else if( i == 1 ){ a = 'E';} else if( i == 2 ){ a = 'Y';} else if( i > 2 ){ a = x;} i++; return x + a; }
When I pipe a message through encrypt then through decrypt I should get the original message but I only get the first 3 characters (because of the first three K E Y keywords) and any numbers in the message. Any other characters don't come out correctly. What am I missing? Thanks in advance.Code:unsigned int decrypt(char x){ char a; if( i == 0 ){ a = 'K';} else if( i == 1 ){ a = 'E';} else if( i == 2 ){ a = 'Y';} else if( i > 2 ){ a = (x/2);} i++; if (c != EOF && c != ('\n')){ return x - a;} else {return 0;} }