Free2Code
 
Time: 2008-11-21, 08:11pm
Opinion..
Subject: Opinion..  ·  Posted: 2006-05-25, 09:03pm
Rank: ? (8)
Member #: 27517
I tried to create my own encryption program using the XOR operator. I need your opinion on this...how I can improve it, why it will never work, etc etc...thanks.

//Encryption Process
else if (!strcmp(argv[1], "encrypt") {

char input[21];
cout << "Enter word: ";
cin >> input;

char key1 = 'a'; //key to be XOR
char key2 = 'b'; //another key to be XOR

int x = strlen(input); //get length of string and assign to x
char word[x]; //a character array with the same length as the string
strcpy(word, input); //put the input to the character word array

cout << "Encrypted word: ";

//loop through the elements of "word" while XOR each element to key1 then to key2
for(int i = 0; i < x; i++) {
word [i] = word[i] ^ key1 ^ key2;
cout << word[i];
}
cout << endl;

}


MAGIS
 
  Reply to this ·  Post link ·  Top
Subject: Re: Opinion..  ·  Posted: 2006-09-14, 03:29am
Rank: ? (119)
Member #: 28292
The problem could appear when after xoring the symbol could become a control character with value x for 0 <= x <= 32. These could be read false or it could become the symbol of EOF (End of file) which will stop reading.

 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons