Quote Originally Posted by XSquared View Post
Aah. Xoring with a seeded random number generator. Not portable, unfortunately. I doubt I would have ever broken it (if you hadn't posted the encrypted source code), due to the fact that the RNG on my machine gives different output than the one on the machine that encrypted these text files.
Yeah. The full quote of what I trimmed is as follows:
Quote Originally Posted by C Unleashed
Code:
void encrypt(char* p, unsigned key)
{
   srand(key);
   while(*p)
   {
      *p++ ^= rand();
   }
}
This is more secure than the first, but not by much. This basic algorithm, with a few variations, is the most common "home grown" encryption algorithm. The first problem is that the rand() function is not guaranteed to produce random values -- in fact, it is intended to produce pseudorandom values. Although truly random values are quite secure, pseudorandom values contain detectable patterns. Additionally, the seed is only a single unsigned int value. It takes only a minute or two to try every possible key value, even on a slow computer. The messages could be decoded and the key discovered very easily without even invoking elementary cryptanalysis. Still another reason to frown on this code is that differences in rand() implementations make it very nonportable. Any other library implementations are likely to be incompativle and fail to properly decrypt another's ciphertext.
Please forgive any typos in the above.

Quote Originally Posted by XSquared View Post
Also, as for how I cracked it, I had a program which XORed two arbitrary files, and when I ran it on multiple sets of plain/ciphers, I noticed that the result was the same. I had no clue how he was generating the key, so I just XORed the data file with the encrypted source to get the plain-text source.
Perhaps posting that was an oversight on my part.

The real situation from way back that my first post in this thread was inspired by was a little more complicated that this as well, but probably in the same family.