Introduction
XOR encryption is a trivially simple symmetric cipher which is used in many applications where security is not a defined requirement.Exclusive-OR encryption, while not a public-key system such as RSA, is almost unbreakable through brute force methods. It is susceptible to patterns, but this weakness can be avoided through first compressing the file (so as to remove patterns). Exclusive-or encryption requires that both encryptor and decryptor have access to the encryption key, but the encryption algorithm, while extremely simple, is nearly unbreakable.
Code:
A ^ 0 = A A ^ A = 0 B ^ A ^ A = B ^ 0 = B
The XOR operator is extremely common as a component in more complex ciphers. By itself, using a constant repeating key, a simple XOR cipher can trivially be broken using frequency analysis. Its primary merit is that it is simple to implement, and that the XOR operation is computationally inexpensive.
Recently, probably the makers of a media player 3wplayer(reported by Norton Antivirus as a spyware threat), encoded DVD rip avi files and put them up on torrent portals.
One intelligent guy amazingly figured out the hidden trick and decrypted the avi file, which otherwise can only be played in 3wplayer. Read more about it here http://forum.mininova.org/index.php?showtopic=234994521
An Example
Code: PHP
// Let's define our key here
$key = 'G4E';
// Our plaintext/ciphertext
$text = 'Programming Forums';
// Our output text
$outText = '';
// Iterate through each character
for($i=0;$i<strlen($text);$i++)
{
for($j=0;$j<strlen($key);$j++,$i++)
{
$outText .= $text{$i} ^ $key{$j};
}
}

